Skip to content

Commit 6b8622a

Browse files
committed
Timer.update was calling the TimerEvent callback even if TimerEvent.pendingDelete was already set to true, causing timer events to stack-up in cases where a new TimerEvent was generated in the callback (thanks @clowerweb phaserjs#838)
1 parent 74bee32 commit 6b8622a

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ Thanks to @pnstickne for vast majority of this update.
144144
* You can now tint animated Sprites in Canvas mode. Or change the texture atlas frame of a tinted Sprite or Image. Please note that this is pretty expensive (depending in the browser), as the tint is re-applied every time the *frame changes*. The Pixi tint cache has also been removed to allow for subtle tint color shifts and to avoid blowing up memory. So use this feature sparingly! But at least it does now work (#1070)
145145
* ArcadePhysics.moveToPointer no longer goes crazy if the maxTime parameter is given and the Sprite is positioned in a larger game world (thanks @AnderbergE #1472)
146146
* Sound.loop even when set for WebAudio wouldn't use the AudioContext loop property because Sound.start was being invoked with an offset and duration. Now if `loop` is true and no marker is being used it will use the native Web Audio loop support (#1431)
147+
* Timer.update was calling the TimerEvent callback even if `TimerEvent.pendingDelete` was already set to `true`, causing timer events to stack-up in cases where a new TimerEvent was generated in the callback (thanks @clowerweb #838)
147148

148149
For changes in previous releases please see the extensive [Version History](https://github.com/photonstorm/phaser/blob/master/CHANGELOG.md).
149150

src/time/Timer.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ Phaser.Timer = function (game, autoDestroy) {
8181
/**
8282
* @property {number} timeCap - If the difference in time between two frame updates exceeds this value, the event times are reset to avoid catch-up situations.
8383
*/
84-
// this.timeCap = 1 / 60 * 1000;
8584
this.timeCap = 1000;
8685

8786
/**
@@ -448,7 +447,7 @@ Phaser.Timer.prototype = {
448447
{
449448
while (this._i < this._len && this.running)
450449
{
451-
if (this._now >= this.events[this._i].tick)
450+
if (this._now >= this.events[this._i].tick && !this.events[this._i].pendingDelete)
452451
{
453452
// (now + delay) - (time difference from last tick to now)
454453
this._newTick = (this._now + this.events[this._i].delay) - (this._now - this.events[this._i].tick);

0 commit comments

Comments
 (0)