修复运行时未初始化

This commit is contained in:
yhh
2020-07-23 19:28:01 +08:00
parent 79c5d6990c
commit d4c244daf5
18 changed files with 283 additions and 303 deletions

View File

@@ -3,10 +3,6 @@ module es {
* 全局核心类
*/
export class Core extends egret.DisplayObjectContainer {
/**
* 订阅此事件以在活动场景发生更改时得到通知。
*/
public static activeSceneChanged: Function;
/**
* 核心发射器。只发出核心级别的事件
*/
@@ -44,6 +40,8 @@ module es {
* 当前活动的场景。注意,如果设置了该设置,在更新结束之前场景实际上不会改变
*/
public static get scene() {
if (!this._instance)
return null;
return this._instance._scene;
}
@@ -64,8 +62,6 @@ module es {
} else {
this._instance._nextScene = value;
}
this.registerActiveSceneChanged(this._instance._scene, this._instance._nextScene);
}
constructor() {
@@ -73,14 +69,20 @@ module es {
Core._instance = this;
Core.emitter = new Emitter<CoreEvents>();
Core.graphicsDevice = new GraphicsDevice();
Core.content = new ContentManager();
this.addEventListener(egret.Event.ADDED_TO_STAGE, this.initialize, this);
this.addEventListener(egret.Event.ADDED_TO_STAGE, this.onAddToStage, this);
}
private onAddToStage(){
Core.graphicsDevice = new GraphicsDevice();
this.addEventListener(egret.Event.RESIZE, this.onGraphicsDeviceReset, this);
this.addEventListener(egret.StageOrientationEvent.ORIENTATION_CHANGE, this.onOrientationChanged, this);
this.addEventListener(egret.Event.ENTER_FRAME, this.update, this);
this.addEventListener(egret.Event.RENDER, this.draw, this);
this.initialize();
}
public onOrientationChanged(){
@@ -190,11 +192,6 @@ module es {
return sceneTransition;
}
public static registerActiveSceneChanged(current: Scene, next: Scene){
if (this.activeSceneChanged)
this.activeSceneChanged(current, next);
}
/**
* 添加一个全局管理器对象,它的更新方法将调用场景前的每一帧。
* @param manager

View File

@@ -6,6 +6,8 @@ module es {
}
private platformInitialize(device: GraphicsDevice){
if (GraphicsCapabilities.runtimeType != egret.RuntimeType.WXGAME)
return;
let capabilities = this;
capabilities["isMobile"] = true;

View File

@@ -17,7 +17,12 @@ module es {
public static readonly logSnapDuration = 120;
public static readonly barPadding = 2;
public static readonly autoAdjustDelay = 30;
public static Instance: TimeRuler;
private static _instance;
public static get Instance(): TimeRuler{
if (!this._instance)
this._instance = new TimeRuler();
return this._instance;
}
private _frameKey = 'frame';
private _logKey = 'log';
@@ -56,7 +61,6 @@ module es {
private _frameAdjust: number;
constructor() {
TimeRuler.Instance = this;
this._logs = new Array<FrameLog>(2);
for (let i = 0; i < this._logs.length; ++i)
this._logs[i] = new FrameLog();