/
muybridge.js
49 lines (40 loc) · 1001 Bytes
/
muybridge.js
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
class Example extends Phaser.Scene
{
constructor ()
{
super();
}
preload ()
{
this.load.spritesheet('muybridge', 'assets/animations/muybridge01.png', { frameWidth: 119, frameHeight: 228 });
}
create ()
{
const config = {
key: 'run',
frames: 'muybridge',
frameRate: 15,
repeat: -1
};
this.anims.create(config);
// Each frame is 119px wide
const group = this.add.group();
group.createMultiple({
key: 'muybridge',
frame: 10,
repeat: 7,
setOrigin: { x: 0, y: 0.5 },
setXY: { x: 0, y: 300, stepX: 119 }
});
this.anims.staggerPlay('run', group.getChildren(), -100, false);
}
}
const config = {
type: Phaser.WEBGL,
parent: 'phaser-example',
width: 952,
height: 600,
backgroundColor: '#efefef',
scene: Example
};
const game = new Phaser.Game(config);