sceneChanged事件

This commit is contained in:
YHH
2020-07-12 23:30:48 +08:00
parent 032b293085
commit 14598f08c7
9 changed files with 53 additions and 9 deletions

View File

@@ -661,7 +661,10 @@ declare class Time {
static timeScale: number;
static frameCount: number;
private static _lastTime;
static _timeSinceSceneLoad: any;
static update(currentTime: number): void;
static sceneChanged(): void;
static checkEvery(interval: number): boolean;
}
declare class GraphicsCapabilities {
supportsTextureFilterAnisotropic: boolean;
@@ -1043,7 +1046,7 @@ declare class Emitter<T> {
constructor();
addObserver(eventType: T, handler: Function): void;
removeObserver(eventType: T, handler: Function): void;
emit(eventType: T, data: any): void;
emit(eventType: T, data?: any): void;
}
declare class GlobalManager {
static globalManagers: GlobalManager[];

View File

@@ -1489,6 +1489,8 @@ var SceneManager = (function () {
this.activeSceneChanged(current, next);
};
SceneManager.prototype.onSceneChanged = function () {
SceneManager.emitter.emit(CoreEvents.SceneChanged);
Time.sceneChanged();
};
return SceneManager;
}());
@@ -3036,14 +3038,20 @@ var RenderableComponentList = (function () {
var Time = (function () {
function Time() {
}
;
Time.update = function (currentTime) {
var dt = (currentTime - this._lastTime) / 1000;
this.deltaTime = dt * this.timeScale;
this.unscaledDeltaTime = dt;
this._timeSinceSceneLoad += dt;
this.frameCount++;
this._lastTime = currentTime;
};
Time.sceneChanged = function () {
this._timeSinceSceneLoad = 0;
};
Time.checkEvery = function (interval) {
return (this._timeSinceSceneLoad / interval) > ((this._timeSinceSceneLoad - this.deltaTime) / interval);
};
Time.deltaTime = 0;
Time.timeScale = 1;
Time.frameCount = 0;

File diff suppressed because one or more lines are too long