Skip to content

Commit ec5f3d3

Browse files
committed
The TimeStep.step method no longer uses the time value passed to the raf callback, as it's not actually the current point in time, but rather the time that the main thread began at. Which doesn't help if we're comparing it to event timestamps.
1 parent b9ae468 commit ec5f3d3

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

src/core/TimeStep.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -436,11 +436,14 @@ var TimeStep = new Class({
436436
*
437437
* @method Phaser.Core.TimeStep#step
438438
* @since 3.0.0
439-
*
440-
* @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout.
441439
*/
442-
step: function (time)
440+
step: function ()
443441
{
442+
// Because the timestamp passed in from raf represents the beginning of the main thread frame that we’re currently in,
443+
// not the actual time now. As we want to compare this time value against Event timeStamps and the like, we need a
444+
// more accurate one:
445+
var time = window.performance.now();
446+
444447
var before = time - this.lastTime;
445448

446449
if (before < 0)
@@ -562,7 +565,7 @@ var TimeStep = new Class({
562565
*/
563566
tick: function ()
564567
{
565-
this.step(window.performance.now());
568+
this.step();
566569
},
567570

568571
/**

0 commit comments

Comments
 (0)