-
Notifications
You must be signed in to change notification settings - Fork 0
/
endScene.js
66 lines (54 loc) · 2.05 KB
/
endScene.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
class EndScene extends Phaser.Scene {
constructor() {
super({ key: 'endScene' });
this.starfield = null;
this.gameover =null
this.score = 0;
this.restart = null;
this.goToHome = null;
}
init(data){
this.points=data.points;
}
preload() {
this.load.image("starfield", "assets/starfield.png");
this.load.image("gameover", "assets/gameover.png");
this.load.image("restart", "assets/replay.png");
this.load.image("menu", "assets/menu.png");
}
create() {
this.starfield = this.add.tileSprite(0, 0, 4000, 1400, "starfield");
this.gameover = this.add.image(650, 150, "gameover");
this.gameover.setScale(0.8);
this.score = this.add.text(570, 250, 'Your Score:'+ this.points , {
fill: '#0f0',
fontSize: '25px'
});
// changes the scene to gameScene
this.restart = this.add.image(500,400, 'restart');
this.restart.setScale(0.5);
this.restart.setInteractive({ useHandCursor: true });
this.restart.on('pointerdown', () => {
this.scene.stop();
var gameScene = this.scene.get('gameScene');
gameScene.scene.restart();
});
// this.playAgain.on('pointerover', () => {this.text.setColor('#ffff00')});
// this.playAgain.on('pointerout', () => {this.text.setColor('#0f0')});
// changes the scene to titleScene
this.goToHome = this.add.image(800,400, 'menu');
this.goToHome.setScale(0.52);
this.goToHome.setInteractive({ useHandCursor: true });
this.goToHome.on('pointerdown', () => {
this.scene.stop();
var titleScene = this.scene.get('titleScene');
titleScene.scene.restart();
});
// this.goToHome.on('pointerover', () => {this.text.setColor('#ffff00')});
// this.goToHome.on('pointerout', () => {this.text.setColor('#0f0')});
}
update() {
this.starfield.tilePositionY -= 2;
}
}
export default EndScene;