/
countscene.js
90 lines (78 loc) · 2.41 KB
/
countscene.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
/*
* countscene.js
*/
;(function() {
tm.define("tm.game.CountScene", {
superClass: "tm.app.Scene",
init: function(param) {
this.superInit();
param = param.$safe({
width: 640,
height: 960,
bgColor: '#444',
count: 3,
autopop: true,
fontSize: 180,
});
param = param || {};
this.fromJSON({
children: {
bg: {
type: "tm.display.Shape",
width: param.width,
height: param.height,
bgColor: param.bgColor,
originX: 0,
originY: 0,
},
label: {
type: "tm.display.Label",
fillStyle: "white",
fontSize: param.fontSize,
x: SCREEN_CENTER_X,
y: SCREEN_CENTER_Y,
},
}
});
if (param.count instanceof Array) {
this.countList = param.count.reverse();
}
else {
this.countList = Array.range(1, param.count+1);
}
this.counter = this.countList.length;
this.autopop = param.autopop;
this._updateCount();
},
_updateCount: function() {
var endFlag = this.counter <= 0;
var index = --this.counter;
this.label.text = this.countList[index];
this.label.scale.set(1, 1);
this.label.tweener
.clear()
.to({
scaleX: 1,
scaleY: 1,
alpha: 1,
}, 250)
.wait(500)
.to({
scaleX: 1.5,
scaleY: 1.5,
alpha: 0.0
}, 250)
.call(function() {
if (this.counter <= 0) {
this.flare('finish');
if (this.autopop) {
this.app.popScene();
}
}
else {
this._updateCount();
}
}, this);
},
});
})();