-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgameOver.js
More file actions
41 lines (36 loc) · 1.29 KB
/
gameOver.js
File metadata and controls
41 lines (36 loc) · 1.29 KB
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
export default class GameOver {
preload() {
this.game.load.image('Court', './assets/background2.jpg')
this.load.spritesheet('returnToHome', './assets/button_hauptmenu.png', 157, 40);
this.load.spritesheet('playAgain', './assets/button_neues-spiel.png', 154, 40);
}
create() {
this.add.image(0, 0, 'Court')
this.add.button(this.world.centerX - 80, 550, 'returnToHome', this.returnToHome,this, 2, 1, 0);
this.add.button(this.world.centerX - 80, 460, 'playAgain', this.playsameAgain,this, 2, 1, 0);
const winner = localStorage.getItem('winner');
const result = JSON.parse(localStorage.getItem('gameResult'));
result.player1
result.player2
this.game.add.text(80, 90, ` ${winner} \n hat gewonnen`, {
font: "48px Arial",
fill: "#fff",
algin: "center"
});
this.game.add.text(125, 255, `${result.player1} :`, {
font: "128px Arial",
fill: "#EC0909"
});
this.game.add.text(295, 255, result.player2, {
font: "128px Arial",
fill: "#EC0909",
});
}
update() {}
returnToHome() {
this.state.start('welcome');
}
playsameAgain() {
this.state.start('game')
}
}