-
Notifications
You must be signed in to change notification settings - Fork 1
/
EndGame.js
102 lines (91 loc) · 2.39 KB
/
EndGame.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
Game.EndGame = function(game) {};
Game.EndGame.prototype = {
create: function(game) {
//screen size will be set automatically
this.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL;
this.scale.pageAlignHorizontally = true;
this.scale.pageAlignVertically = true;
this.scale.setScreenSize(true);
this.timeup = this.game.add.image(
this.game.world.centerX,
this.game.world.centerY - this.game.cache.getImage("timeup").height,
"timeup"
);
this.timeup.anchor.set(0.5, 0.5);
this.timeup.alpha = 0;
this.game.add
.tween(this.timeup)
.to({ alpha: 1 }, 2000, Phaser.Easing.Linear.None, true);
console.log(score);
this.createScore();
this.createMenuBtn();
},
createScore: function() {
this.scoreTable = this.game.add.image(
this.game.world.centerX,
this.game.renderer.height - this.game.cache.getImage("bg-score").height,
"bg-score"
);
this.scoreTable.scale.setTo(0.7);
this.scoreTable.anchor.set(0.5, 0.5);
this.scoreLabel = this.game.add.text(
this.scoreTable.x,
this.scoreTable.y,
score,
{
font: "50px Fredoka One",
fill: "#fff",
align: "right"
}
);
this.scoreLabel.anchor.setTo(0.5, 0.6);
this.scoreTable.alpha = 0;
this.scoreLabel.alpha = 0;
this.game.add
.tween(this.scoreTable)
.to({ alpha: 1 }, 2000, Phaser.Easing.Linear.None, true, 2000);
this.game.add
.tween(this.scoreLabel)
.to({ alpha: 1 }, 2000, Phaser.Easing.Linear.None, true, 2000);
this.game.add.tween(this.scoreTable.scale).to(
{ x: 1.1, y: 1.1 },
1000,
Phaser.Easing.Linear.None,
true,
1,
1,
1000,
true,
3000
);
this.game.add
.tween(this.scoreLabel.scale)
.to(
{ x: 1.8, y: 1.8 },
1000,
Phaser.Easing.Linear.None,
true,
1,
1,
1000,
true,
3000
);
},
createMenuBtn: function() {
btn_menu = this.game.add.button(
this.game.world.centerX,
this.game.world.centerY + 200,
"btn-return",
function() {
this.game.state.start("MainMenu");
}
);
btn_menu.anchor.set(0.5, 0.5);
btn_menu.alpha = 0;
btn_menu.scale.setTo(0.8, 0.8);
this.game.add
.tween(btn_menu)
.to({ alpha: 1 }, 2000, Phaser.Easing.Linear.None, true, 4000);
}
};