Skip to content

Commit

Permalink
fix count scene
Browse files Browse the repository at this point in the history
  • Loading branch information
phi-jp committed Apr 7, 2015
1 parent 0325d3a commit 39df58d
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/game/countscene.js
Expand Up @@ -16,6 +16,7 @@
bgColor: '#444',
count: 3,
autopop: true,
fontSize: 180,
});

param = param || {};
Expand All @@ -33,22 +34,29 @@
label: {
type: "tm.display.Label",
fillStyle: "white",
fontSize: 200,
fontSize: param.fontSize,
x: SCREEN_CENTER_X,
y: SCREEN_CENTER_Y,
},
}
});

this.counter = param.count;
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.counter--;
this.label.text = this.countList[index];

this.label.scale.set(1, 1);
this.label.tweener
Expand Down
54 changes: 54 additions & 0 deletions test/game/scene.js
Expand Up @@ -422,6 +422,60 @@ testhelper.describe("tm.game.ManagerScene", function() {



testhelper.describe("tm.game.CountScene", function() {

testhelper.it("init", function() {

tm.define("MainScene", {
superClass: "tm.game.CountScene",

init: function() {
this.superInit({
count: 10,
});
},
onfinish: function() {
console.log("finish!");
},
});
});

testhelper.it("start", function() {

tm.define("MainScene", {
superClass: "tm.game.CountScene",

init: function() {
this.superInit({
count: [3, 2, 1, 'Start'],
fontSize: 100,
});
},
onfinish: function() {
console.log("finish!");
},
});
});

testhelper.it("ready", function() {

tm.define("MainScene", {
superClass: "tm.game.CountScene",

init: function() {
this.superInit({
count: ['Ready'],
fontSize: 100,
});
},
onfinish: function() {
console.log("finish!");
},
});
});

});


;(function() {

Expand Down

0 comments on commit 39df58d

Please sign in to comment.