新增time.totalTime

This commit is contained in:
yhh
2020-11-25 11:37:24 +08:00
parent 101d720f2a
commit 015a3b633a
5 changed files with 14 additions and 13 deletions

View File

@@ -638,11 +638,12 @@ declare class StringUtils {
}
declare module es {
class Time {
static totalTime: number;
static unscaledDeltaTime: any;
static deltaTime: number;
static timeScale: number;
static frameCount: number;
static _timeSinceSceneLoad: any;
static timeSinceSceneLoad: any;
private static _lastTime;
static update(currentTime: number): void;
static sceneChanged(): void;

View File

@@ -3136,17 +3136,18 @@ var es;
}
Time.update = function (currentTime) {
var dt = (currentTime - this._lastTime) / 1000;
this.totalTime += dt;
this.deltaTime = dt * this.timeScale;
this.unscaledDeltaTime = dt;
this._timeSinceSceneLoad += dt;
this.timeSinceSceneLoad += dt;
this.frameCount++;
this._lastTime = currentTime;
};
Time.sceneChanged = function () {
this._timeSinceSceneLoad = 0;
this.timeSinceSceneLoad = 0;
};
Time.checkEvery = function (interval) {
return Math.floor(this._timeSinceSceneLoad / interval) > Math.floor((this._timeSinceSceneLoad - this.deltaTime) / interval);
return this.timeSinceSceneLoad / interval > (this.timeSinceSceneLoad - this.deltaTime) / interval;
};
Time.deltaTime = 0;
Time.timeScale = 1;

File diff suppressed because one or more lines are too long