Skip to content
Permalink
Browse files

fixed calculateDeltaTime error

  • Loading branch information
Jno1995 authored and jareguo committed Dec 24, 2019
1 parent 6322455 commit e222465ce8426e5cf32052e4f37701f3a529ed18
Showing with 3 additions and 7 deletions.
  1. +3 −7 cocos2d/core/CCDirector.js
@@ -217,16 +217,12 @@ cc.Director.prototype = {
*/
calculateDeltaTime: function (now) {
if (!now) now = performance.now();
this._deltaTime = (now - this._lastUpdate) / 1000;
if (CC_DEBUG && (this._deltaTime > 1))
this._deltaTime = 1 / 60.0;

// avoid delta time from being negative
// negative deltaTime would be caused by the precision of now's value, for details please see: https://developer.mozilla.org/zh-CN/docs/Web/API/window/requestAnimationFrame
if (this._deltaTime < 0) {
this.calculateDeltaTime();
return;
}
this._deltaTime = now > this._lastUpdate ? (now - this._lastUpdate) / 1000 : 0;
if (CC_DEBUG && (this._deltaTime > 1))
this._deltaTime = 1 / 60.0;

this._lastUpdate = now;
},

0 comments on commit e222465

Please sign in to comment.
You can’t perform that action at this time.