mirror of
https://github.com/photonstorm/phaser
synced 2024-11-23 13:13:43 +00:00
22 lines
1.1 KiB
JavaScript
22 lines
1.1 KiB
JavaScript
/// <reference path="../../Phaser/Game.ts" />
|
|
(function () {
|
|
var game = new Phaser.Game(this, 'game', 320, 200, init, create);
|
|
function init() {
|
|
// Using Phasers asset loader we load up a PNG from the assets folder
|
|
game.load.spritesheet('monster', '../assets/sprites/metalslug_monster39x40.png', 39, 40);
|
|
game.load.start();
|
|
}
|
|
var monster;
|
|
function create() {
|
|
game.stage.backgroundColor = 'rgb(50,10,10)';
|
|
// Notice the use of 'stage.centerX' - this places the sprite in the middle of the stage without needing to do any extra math
|
|
monster = game.add.sprite(100, 50, 'monster');
|
|
// For this animation we pass 'null' for the frames, because we're going to use them all
|
|
// And we set the frame rate (30) and loop status (true) when we add the animation
|
|
// If the frame rate and looping is never going to change then it's easier to do it here
|
|
monster.animations.add('walk', null, 30, true);
|
|
// Then you can just call 'play' on its own with no other values to start things going
|
|
monster.animations.play('walk');
|
|
monster.scale.setTo(3, 3);
|
|
}
|
|
})();
|