-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
55 lines (38 loc) · 995 Bytes
/
main.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
50
51
52
53
54
55
class AlignAnimations extends Phaser.Scene {
constructor ()
{
super();
};
preload () {
this.load.spritesheet('animation', 'assets/sprites/spritesheet.png', {frameWidth: 24, frameHeight: 24});
};
create () {
this.anims.create({
key: 'move',
frames: this.anims.generateFrameNumbers('animation'),
frameRate: 2,
repeat: -1
});
const sprites = []
for (let i = 0; i < 240; i++) {
sprites.push(this.add.sprite(0, 0, 'animation').play('move'));
}
Phaser.Actions.GridAlign(sprites, {
width: 24,
cellWidth: 30,
cellHeight: 30,
x: 50,
y: 100
});
};
};
const config = {
type: Phaser.AUTO,
width: 800,
height: 600,
backgroundColor: '#2d2d2d',
parent: 'phaser-example',
scene: AlignAnimations
};
// creación del juego
const game = new Phaser.Game(config);