Merge pull request #1657 from player-03/html5-now
Use `performance.now()` for HTML5 timing.
This commit is contained in:
@@ -325,7 +325,7 @@ class HTML5Application
|
|||||||
|
|
||||||
if (!window.requestAnimationFrame)
|
if (!window.requestAnimationFrame)
|
||||||
window.requestAnimationFrame = function(callback, element) {
|
window.requestAnimationFrame = function(callback, element) {
|
||||||
var currTime = new Date().getTime();
|
var currTime = window.performance.now();
|
||||||
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
|
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
|
||||||
var id = window.setTimeout(function() { callback(currTime + timeToCall); },
|
var id = window.setTimeout(function() { callback(currTime + timeToCall); },
|
||||||
timeToCall);
|
timeToCall);
|
||||||
@@ -341,7 +341,7 @@ class HTML5Application
|
|||||||
window.requestAnimFrame = window.requestAnimationFrame;
|
window.requestAnimFrame = window.requestAnimationFrame;
|
||||||
");
|
");
|
||||||
|
|
||||||
lastUpdate = Date.now().getTime();
|
lastUpdate = Browser.window.performance.now();
|
||||||
|
|
||||||
handleApplicationEvent();
|
handleApplicationEvent();
|
||||||
|
|
||||||
@@ -361,7 +361,7 @@ class HTML5Application
|
|||||||
|
|
||||||
updateGameDevices();
|
updateGameDevices();
|
||||||
|
|
||||||
currentUpdate = Date.now().getTime();
|
currentUpdate = Browser.window.performance.now();
|
||||||
|
|
||||||
if (currentUpdate >= nextUpdate)
|
if (currentUpdate >= nextUpdate)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user