mirror of
https://github.com/photonstorm/phaser
synced 2024-11-23 13:13:43 +00:00
Swapped to perf.now.
This commit is contained in:
parent
54442c59d4
commit
17d6667c63
1 changed files with 9 additions and 7 deletions
|
@ -48,8 +48,10 @@ TickerLoop.prototype = {
|
|||
this.started = true;
|
||||
this.running = true;
|
||||
|
||||
this.startTime = Date.now();
|
||||
this.lastUpdate = Date.now();
|
||||
var now = window.performance.now();
|
||||
|
||||
this.startTime = now;
|
||||
this.lastUpdate = now;
|
||||
|
||||
this.useRAF = useRAF;
|
||||
this.callback = callback;
|
||||
|
@ -57,9 +59,9 @@ TickerLoop.prototype = {
|
|||
this.raf.start(this.step.bind(this), useRAF);
|
||||
},
|
||||
|
||||
step: function (manual)
|
||||
step: function (time, manual)
|
||||
{
|
||||
var elapsed = Date.now() - this.lastUpdate;
|
||||
var elapsed = time - this.lastUpdate;
|
||||
|
||||
if (elapsed > this.lagThreshold)
|
||||
{
|
||||
|
@ -68,15 +70,15 @@ TickerLoop.prototype = {
|
|||
|
||||
this.lastUpdate += elapsed;
|
||||
|
||||
var time = (this.lastUpdate - this.startTime) / 1000;
|
||||
var dt = (this.lastUpdate - this.startTime) / 1000;
|
||||
|
||||
this.elapsed = elapsed;
|
||||
|
||||
var overlap = time - this.nextTime;
|
||||
var overlap = dt - this.nextTime;
|
||||
|
||||
this.overlap = overlap;
|
||||
|
||||
this.time = time;
|
||||
this.time = dt;
|
||||
|
||||
if (overlap > 0 || manual)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue