-
Notifications
You must be signed in to change notification settings - Fork 1
/
text-object.js
68 lines (66 loc) · 1.68 KB
/
text-object.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
'use strict';
class TextObject {
constructor (x, y, value, time) {
this.style = { font: "bold 32px Pixelade", fill: "#10BB10", boundsAlignH: "left"};
this.text = game.add.text(0, 0, value, this.style);
this.text.x = x;
this.text.y = y - 100;
this.time = time;
this.text.setShadow(3, 3, 'rgba(0,0,0,0.5)', 2)
}
update(deltaTime){
this.text.y -= deltaTime * 40;
this.time -= deltaTime * 1;
this.text.alpha += 3;
if (this.text.alpha > 255){
this.text.alpha = 255;
}
return (this.time);
}
destroy(){
this.text.destroy();
this.text.kill();
}
}
class ComboText {
constructor (){
this.countKilled = 0;
this.nbCombos = 0;
this.remainingTime = 0;
this.style = { font: "32px Pixelade", fill: "#BB1010", boundsAlignH: "center", boundsAlignV: "middle"};
this.text = game.add.text(0, 0, "COMBO : " + this.nbCombos, this.style);
this.text.setShadow(3, 3, 'rgba(0,0,0,0.5)', 2)
this.text.setTextBounds(0, 100, game.world.width, 100);
}
update(deltaTime){
if (this.remainingTime > 0){
this.remainingTime -= deltaTime;
}
else {
this.nbCombos = 0;
this.remainingTime = 0;
this.text.visible = false;
this.text.fontSize = 32;
}
if (this.countKilled < waveAttack.humansKilled){
let diff = waveAttack.humansKilled - this.countKilled;
this.nbCombos += diff;
this.countKilled += diff;
this.remainingTime = 3;
if (this.nbCombos > 1){
this.text.visible = true;
}
this.text.fontSize = 32 - 2 + this.nbCombos;
}
this.text.text = "COMBO : " + this.nbCombos;
}
setVisibility(value){
this.text.visible = value;
}
resetCombo(){
this.nbCombos = 0;
this.remainingTime = 0;
this.text.visible = false;
this.text.fontSize = 32;
}
}