2013-05-29 14:45:34 +00:00
|
|
|
/// <reference path="../../Phaser/Game.ts" />
|
|
|
|
|
|
|
|
(function () {
|
|
|
|
|
2013-08-08 03:35:13 +00:00
|
|
|
var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
|
2013-05-29 14:45:34 +00:00
|
|
|
|
2013-08-08 03:35:13 +00:00
|
|
|
function preload() {
|
2013-05-29 14:45:34 +00:00
|
|
|
|
|
|
|
// Using Phasers asset loader we load up a PNG from the assets folder
|
|
|
|
|
|
|
|
// The sprite sheet is a standard frame-by-frame sheet, and each frame is 37 x 45 pixels in size.
|
|
|
|
// The final parameter (18) is the number of frames there are. You can omit this if your frames fill the entire sheet.
|
2013-06-05 01:58:16 +00:00
|
|
|
game.load.spritesheet('mummy', 'assets/sprites/metalslug_mummy37x45.png', 37, 45, 18);
|
2013-08-08 03:35:13 +00:00
|
|
|
|
2013-05-29 14:45:34 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
var mummy: Phaser.Sprite;
|
|
|
|
|
|
|
|
function create() {
|
|
|
|
|
|
|
|
mummy = game.add.sprite(game.stage.centerX, game.stage.centerY, 'mummy');
|
|
|
|
|
|
|
|
// Here we add new animation called 'walk'.
|
|
|
|
// As it's the only animation in our sprite sheet we don't need to define the frames being used.
|
|
|
|
mummy.animations.add('walk');
|
|
|
|
|
|
|
|
// This plays the animation at 20 frames per second on a loop (the 3rd parameter)
|
|
|
|
// Try changing the 20 value to something low to slow the speed down, or higher to make it play faster.
|
|
|
|
mummy.animations.play('walk', 20, true);
|
|
|
|
|
|
|
|
// This just scales the sprite up so you can see the animation better
|
2013-06-06 01:47:08 +00:00
|
|
|
mummy.transform.scale.setTo(4, 4);
|
2013-05-29 14:45:34 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})();
|