Skip to content

Commit

Permalink
the odometer counter now stacks the the points refs #16 #game
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelstary committed Feb 19, 2015
1 parent 43553ea commit 57c4743
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions www/js/myscenes/component/OdometerView.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,21 @@ var OdometerView = (function (ScoreBoard, Transition, Math) {
this.stage = stage;
this.countDrawables = countDrawables;
this.shaker = shaker;
this.stack = [];
this.moving = false
}

OdometerView.prototype.animateTransition = function (digitPosition, oldValue, newValue) {
if (this.moving) {
this.stack.push(this.__animateTransition.bind(this, digitPosition, oldValue, newValue));
return;
}

this.__animateTransition(digitPosition, oldValue, newValue);
};

OdometerView.prototype.__animateTransition = function (digitPosition, oldValue, newValue) {
this.moving = true;
var currentDrawable = this.countDrawables[digitPosition];

var getX;
Expand Down Expand Up @@ -39,6 +51,9 @@ var OdometerView = (function (ScoreBoard, Transition, Math) {
var newDrawable = this.stage.moveFreshText(getX, getLowerY, newValue.toString(), ScoreBoard.getSize,
ScoreBoard.font, ScoreBoard.color, getX, ScoreBoard.getY, speed, spacing, false, function () {
self.stage.unmask(newDrawable);
self.moving = false;
if (self.stack.length > 0)
self.stack.shift()();
}).drawable;
this.countDrawables.splice(digitPosition, 1, newDrawable);
this.shaker.add(newDrawable);
Expand Down

0 comments on commit 57c4743

Please sign in to comment.