1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 | // ex15. Animation
var GameState = {
preload: function() {
game.load.spritesheet('colorImages', 'images/ex15.png', 32, 32, 4);
},
create: function() {
// Set backgound color
game.stage.backgroundColor = "#555555";
// add first frame
this.color = game.add.sprite(game.world.centerX,
game.world.centerY, 'colorImages');
this.color.anchor.setTo(0.5);
this.color.scale.set(4);
// create looped animation
this.color.animations.add('colorAnimation', [0, 1, 2, 3], 2, true);
// start
this.color.animations.play("colorAnimation");
}
}
var game = new Phaser.Game(800, 600, Phaser.AUTO);
game.state.add("GameState", GameState);
game.state.start("GameState");
|
No comments:
Post a Comment