2020-06-08 21:53:09 +08:00
|
|
|
class Time {
|
|
|
|
|
public static unscaledDeltaTime;
|
2020-06-11 00:03:26 +08:00
|
|
|
public static deltaTime: number = 0;
|
2020-06-08 21:53:09 +08:00
|
|
|
public static timeScale = 1;
|
2020-06-11 00:03:26 +08:00
|
|
|
public static frameCount = 0;;
|
2020-06-08 21:53:09 +08:00
|
|
|
|
|
|
|
|
private static _lastTime = 0;
|
|
|
|
|
|
|
|
|
|
public static update(currentTime: number){
|
|
|
|
|
let dt = (currentTime - this._lastTime) / 1000;
|
|
|
|
|
this.deltaTime = dt * this.timeScale;
|
|
|
|
|
this.unscaledDeltaTime = dt;
|
2020-06-11 00:03:26 +08:00
|
|
|
this.frameCount ++;
|
2020-06-08 21:53:09 +08:00
|
|
|
|
|
|
|
|
this._lastTime = currentTime;
|
|
|
|
|
}
|
|
|
|
|
}
|