修复Time不传入dt获取deltaTime错误问题

This commit is contained in:
yhh
2021-08-05 11:47:47 +08:00
parent 8bc06f0476
commit 0beadf8e5a
5 changed files with 24 additions and 23 deletions

View File

@@ -17,18 +17,19 @@ module es {
public static timeSinceSceneLoad: number = 0;
private static _lastTime = -1;
public static update(currentTime: number) {
if (currentTime == -1) {
currentTime = Date.now();
}
if (this._lastTime == -1)
this._lastTime = currentTime;
public static update(currentTime: number, useEngineTime: boolean) {
let dt = 0;
if (currentTime == -1) {
dt = (currentTime - this._lastTime) / 1000;
} else {
if (useEngineTime) {
dt = currentTime;
} else {
if (currentTime == -1) {
currentTime = Date.now();
}
if (this._lastTime == -1)
this._lastTime = currentTime;
dt = (currentTime - this._lastTime) / 1000;
}
if (dt > this.maxDeltaTime)