修复运行时未初始化
This commit is contained in:
6
source/bin/framework.d.ts
vendored
6
source/bin/framework.d.ts
vendored
@@ -248,7 +248,6 @@ declare module es {
|
||||
}
|
||||
declare module es {
|
||||
class Core extends egret.DisplayObjectContainer {
|
||||
static activeSceneChanged: Function;
|
||||
static emitter: Emitter<CoreEvents>;
|
||||
static graphicsDevice: GraphicsDevice;
|
||||
static content: ContentManager;
|
||||
@@ -260,6 +259,7 @@ declare module es {
|
||||
_globalManagers: GlobalManager[];
|
||||
static scene: Scene;
|
||||
constructor();
|
||||
private onAddToStage;
|
||||
onOrientationChanged(): void;
|
||||
protected onGraphicsDeviceReset(): void;
|
||||
protected initialize(): void;
|
||||
@@ -269,7 +269,6 @@ declare module es {
|
||||
endDebugUpdate(): void;
|
||||
onSceneChanged(): void;
|
||||
static startSceneTransition<T extends SceneTransition>(sceneTransition: T): T;
|
||||
static registerActiveSceneChanged(current: Scene, next: Scene): void;
|
||||
static registerGlobalManager(manager: es.GlobalManager): void;
|
||||
static unregisterGlobalManager(manager: es.GlobalManager): void;
|
||||
static getGlobalManager<T extends es.GlobalManager>(type: any): T;
|
||||
@@ -1679,7 +1678,8 @@ declare module es {
|
||||
static readonly logSnapDuration: number;
|
||||
static readonly barPadding: number;
|
||||
static readonly autoAdjustDelay: number;
|
||||
static Instance: TimeRuler;
|
||||
private static _instance;
|
||||
static readonly Instance: TimeRuler;
|
||||
private _frameKey;
|
||||
private _logKey;
|
||||
private _logs;
|
||||
|
||||
@@ -1105,13 +1105,8 @@ var es;
|
||||
_this._globalManagers = [];
|
||||
Core._instance = _this;
|
||||
Core.emitter = new es.Emitter();
|
||||
Core.graphicsDevice = new es.GraphicsDevice();
|
||||
Core.content = new es.ContentManager();
|
||||
_this.addEventListener(egret.Event.ADDED_TO_STAGE, _this.initialize, _this);
|
||||
_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.addEventListener(egret.Event.ADDED_TO_STAGE, _this.onAddToStage, _this);
|
||||
return _this;
|
||||
}
|
||||
Object.defineProperty(Core, "Instance", {
|
||||
@@ -1123,6 +1118,8 @@ var es;
|
||||
});
|
||||
Object.defineProperty(Core, "scene", {
|
||||
get: function () {
|
||||
if (!this._instance)
|
||||
return null;
|
||||
return this._instance._scene;
|
||||
},
|
||||
set: function (value) {
|
||||
@@ -1138,11 +1135,18 @@ var es;
|
||||
else {
|
||||
this._instance._nextScene = value;
|
||||
}
|
||||
this.registerActiveSceneChanged(this._instance._scene, this._instance._nextScene);
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Core.prototype.onAddToStage = function () {
|
||||
Core.graphicsDevice = new es.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();
|
||||
};
|
||||
Core.prototype.onOrientationChanged = function () {
|
||||
Core.emitter.emit(es.CoreEvents.OrientationChanged);
|
||||
};
|
||||
@@ -1228,10 +1232,6 @@ var es;
|
||||
this._instance._sceneTransition = sceneTransition;
|
||||
return sceneTransition;
|
||||
};
|
||||
Core.registerActiveSceneChanged = function (current, next) {
|
||||
if (this.activeSceneChanged)
|
||||
this.activeSceneChanged(current, next);
|
||||
};
|
||||
Core.registerGlobalManager = function (manager) {
|
||||
this._instance._globalManagers.push(manager);
|
||||
manager.enabled = true;
|
||||
@@ -4308,6 +4308,8 @@ var es;
|
||||
this.platformInitialize(device);
|
||||
};
|
||||
GraphicsCapabilities.prototype.platformInitialize = function (device) {
|
||||
if (GraphicsCapabilities.runtimeType != egret.RuntimeType.WXGAME)
|
||||
return;
|
||||
var capabilities = this;
|
||||
capabilities["isMobile"] = true;
|
||||
var systemInfo = wx.getSystemInfoSync();
|
||||
@@ -7570,7 +7572,6 @@ var es;
|
||||
this.stopwacth = new stopwatch.Stopwatch();
|
||||
this._markerNameToIdMap = new Map();
|
||||
this.showLog = false;
|
||||
TimeRuler.Instance = this;
|
||||
this._logs = new Array(2);
|
||||
for (var i = 0; i < this._logs.length; ++i)
|
||||
this._logs[i] = new FrameLog();
|
||||
@@ -7579,6 +7580,15 @@ var es;
|
||||
es.Core.emitter.addObserver(es.CoreEvents.GraphicsDeviceReset, this.onGraphicsDeviceReset, this);
|
||||
this.onGraphicsDeviceReset();
|
||||
}
|
||||
Object.defineProperty(TimeRuler, "Instance", {
|
||||
get: function () {
|
||||
if (!this._instance)
|
||||
this._instance = new TimeRuler();
|
||||
return this._instance;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
TimeRuler.prototype.onGraphicsDeviceReset = function () {
|
||||
var layout = new es.Layout();
|
||||
this._position = layout.place(new es.Vector2(this.width, TimeRuler.barHeight), 0, 0.01, es.Alignment.bottomCenter).location;
|
||||
|
||||
2
source/bin/framework.min.js
vendored
2
source/bin/framework.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -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
|
||||
|
||||
@@ -6,6 +6,8 @@ module es {
|
||||
}
|
||||
|
||||
private platformInitialize(device: GraphicsDevice){
|
||||
if (GraphicsCapabilities.runtimeType != egret.RuntimeType.WXGAME)
|
||||
return;
|
||||
let capabilities = this;
|
||||
capabilities["isMobile"] = true;
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user