Skip to content

Commit 2de8332

Browse files
committed
Testing Tween timer fix.
1 parent 7487c15 commit 2de8332

2 files changed

Lines changed: 19 additions & 5 deletions

File tree

src/core/Game.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -853,6 +853,10 @@ Phaser.Game.prototype = {
853853
{
854854
break;
855855
}
856+
else
857+
{
858+
this.time.refresh();
859+
}
856860
}
857861

858862
// detect spiraling (if the catch-up loop isn't fast enough, the number of iterations will increase constantly)

src/time/Time.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,19 @@ Phaser.Time.prototype = {
329329

330330
},
331331

332+
refresh: function () {
333+
334+
// Set to the old Date.now value
335+
var previousDateNow = this.time;
336+
337+
// this.time always holds a Date.now value
338+
this.time = Date.now();
339+
340+
// Adjust accordingly.
341+
this.elapsedMS = this.time - previousDateNow;
342+
343+
},
344+
332345
/**
333346
* Updates the game clock and if enabled the advanced timing data. This is called automatically by Phaser.Game.
334347
*
@@ -342,11 +355,7 @@ Phaser.Time.prototype = {
342355
var previousDateNow = this.time;
343356

344357
// this.time always holds a Date.now value
345-
//
346-
// this.now may hold the RAF high resolution time value if RAF is available (otherwise it also holds Date.now)
347-
//
348-
// With SetTimeout the time argument is always the same as Date.now, so no need to get it again
349-
this.time = (this.game.raf._isSetTimeOut) ? time : Date.now();
358+
this.time = Date.now();
350359

351360
// Adjust accordingly.
352361
this.elapsedMS = this.time - previousDateNow;
@@ -355,6 +364,7 @@ Phaser.Time.prototype = {
355364
this.prevTime = this.now;
356365

357366
// update 'now' to hold the current time
367+
// this.now may hold the RAF high resolution time value if RAF is available (otherwise it also holds Date.now)
358368
this.now = time;
359369

360370
// elapsed time between previous call and now - this could be a high resolution value

0 commit comments

Comments
 (0)