Added BitDeli badge, also updating Timer class.

This commit is contained in:
photonstorm
2014-01-03 12:43:58 +00:00
parent c3183dcea9
commit 7aa45b5872
3 changed files with 106 additions and 4 deletions
+43 -4
View File
@@ -55,6 +55,8 @@ Phaser.Timer.prototype = {
this.events.push({
delay: delay,
dispatched: false,
repeatCount: 0,
loop: false,
args: Array.prototype.splice.call(arguments, 1)
});
@@ -68,6 +70,29 @@ Phaser.Timer.prototype = {
},
repeat: function (delay, count) {
this.events.push({
delay: delay,
dispatched: false,
repeatCount: count,
loop: false,
args: Array.prototype.splice.call(arguments, 2)
});
},
loop: function (delay) {
this.events.push({
delay: delay,
dispatched: false,
loop: true,
args: Array.prototype.splice.call(arguments, 2)
});
},
start: function() {
this._started = this.game.time.now;
@@ -100,10 +125,24 @@ Phaser.Timer.prototype = {
{
if (this.events[i].dispatched === false && seconds >= this.events[i].delay)
{
this.events[i].dispatched = true;
// this.events[i].callback.apply(this.events[i].callbackContext, this.events[i].args);
this.onEvent.dispatch.apply(this, this.events[i].args);
// ought to slice it now
if (this.events[i].loop)
{
this.onEvent.dispatch.apply(this, this.events[i].args);
this.events[i].delay = seconds + this.events[i].delay;
}
else if (this.events[i].repeatCount > 0)
{
this.events[i].repeatCount--;
this.onEvent.dispatch.apply(this, this.events[i].args);
this.events[i].delay = seconds + this.events[i].delay;
}
else
{
this.events[i].dispatched = true;
// this.events[i].callback.apply(this.events[i].callbackContext, this.events[i].args);
this.onEvent.dispatch.apply(this, this.events[i].args);
// ought to slice it now
}
}
}
}