-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEndScene.js
78 lines (72 loc) · 1.94 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
67
68
69
70
71
72
73
74
75
76
77
78
class EndScene extends Phaser.Scene {
constructor() {
super({
key: 'EndScene'
})
}
preload() {
this.load.spritesheet('playerWins', './img/won.png', {
frameWidth: 480,
frameHeight: 640
});
this.load.spritesheet('playerLose', './img/lost.png', {
frameWidth: 480,
frameHeight: 640
});
}
create() {
this.add.text(10, 50, 'End Screen', {
fill: '#4D39E0',
fontSize: '45px'
});
if (gameState.player.lives <= 0 && gameState.player.health <= 0) {
// Add the playerLose sprite and animation below:
let lose = this.add.sprite(240, 320, 'playerLose');
this.anims.create({
key: 'lose',
frames: this.anims.generateFrameNames('playerLose', {
start: 0,
end: 1
}),
delay: 0,
frameRate: 2,
repeat: -1
});
lose.anims.play('lose');
} else {
// Add the playerWins sprite and animation below:
let win = this.add.sprite(240, 320, 'playerWins');
this.anims.create({
key: 'win',
frames: this.anims.generateFrameNames('playerWins', {
start: 0,
end: 1
}),
delay: 0,
frameRate: 2,
repeat: -1
});
win.anims.play('win');
}
this.input.on('pointerdown', () => {
// Add logic to transition from EndScene to GameScene
gameState = {
player: {},
computer: {},
computerSprite: {},
playerHealthBar: '',
computerHealthBar: '',
attackButton: '',
defendButton: '',
specialButton: '',
information: '',
playerMove: '',
computerMove: '',
waveCount: 0,
opponents: []
}
this.scene.stop('EndScene');
this.scene.start('GameScene');
})
}
}