-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScene1.js
105 lines (102 loc) · 3.51 KB
/
Scene1.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
class Scene1 extends Phaser.Scene {
constructor() {
super("bootGame");
}
preload() {
this.load.image("background", "assets/images/background.png");
this.load.spritesheet("ship", "assets/images/spritesheets/ship.png",{
frameWidth: 16,
frameHeight: 16
});
this.load.spritesheet("ship2", "assets/images/spritesheets/ship2.png",{
frameWidth: 32,
frameHeight: 16
});
this.load.spritesheet("ship3", "assets/images/spritesheets/ship3.png",{
frameWidth: 32,
frameHeight: 32
});
this.load.spritesheet("explosion", "assets/images/spritesheets/explosion.png",{
frameWidth: 16,
frameHeight: 16
});
this.load.spritesheet("power-up", "assets/images/spritesheets/power-up.png",{
frameWidth: 16,
frameHeight: 16
});
this.load.spritesheet("player", "assets/images/spritesheets/player.png",{
frameWidth: 16,
frameHeight: 24
});
this.load.spritesheet("beam", "assets/images/spritesheets/beam.png",{
frameWidth: 16,
frameHeight: 16
});
this.load.bitmapFont("pixelFont", "assets/font/font.png", "assets/font/font.xml");
// sounds credit: https://soundcloud.com/pascalbelisle
this.load.audio("audio_beam", ["assets/sounds/beam.ogg", "assets/sounds/beam.mp3"])
this.load.audio("audio_explosion", ["assets/sounds/explosion.ogg", "assets/sounds/explosion.mp3"])
this.load.audio("audio_pickup", ["assets/sounds/pickup.ogg", "assets/sounds/pickup.mp3"])
this.load.audio("music", ["assets/sounds/sci-fi_platformer12.ogg", "assets/sounds/sci-fi_platformer12.mp3"])
//this.load.image("colors", "assets/colors.png");
}
create() {
this.add.text(20, 20, "Loading game...");
this.scene.start("playGame");
this.anims.create({
key: "ship1_anim",
frames: this.anims.generateFrameNumbers("ship"),
frameRate: 20,
repeat: -1
});
this.anims.create({
key: "ship2_anim",
frames: this.anims.generateFrameNumbers("ship2"),
frameRate: 20,
repeat: -1
});
this.anims.create({
key: "ship3_anim",
frames: this.anims.generateFrameNumbers("ship3"),
frameRate: 20,
repeat: -1
});
this.anims.create({
key: "explode",
frames: this.anims.generateFrameNumbers("explosion"),
frameRate: 20,
repeat: 0,
hideOnComplete: true
});
this.anims.create({
key: "red",
frames: this.anims.generateFrameNumbers("power-up", {
start: 0,
end: 1
}),
frameRate: 20,
repeat: -1,
});
this.anims.create({
key: "gray",
frames: this.anims.generateFrameNumbers("power-up", {
start: 2,
end: 3
}),
frameRate: 20,
repeat: -1,
});
this.anims.create({
key: "thrust",
frames: this.anims.generateFrameNumbers("player"),
frameRate: 20,
repeat: -1,
});
this.anims.create({
key: "beam_anim",
frames: this.anims.generateFrameNumbers("beam"),
frameRate: 20,
repeat: -1,
});
}
}