SceneManager更改为Core继承egret.DisplayContainer
This commit is contained in:
@@ -7,7 +7,7 @@ module es {
|
||||
public safeArea: Rectangle;
|
||||
|
||||
constructor(){
|
||||
this.clientArea = new Rectangle(0, 0, SceneManager.stage.stageWidth, SceneManager.stage.stageHeight);
|
||||
this.clientArea = new Rectangle(0, 0, Core.graphicsDevice.viewport.width, Core.graphicsDevice.viewport.height);
|
||||
this.safeArea = this.clientArea;
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +62,9 @@ module es {
|
||||
this._logs[i] = new FrameLog();
|
||||
|
||||
this.sampleFrames = this.targetSampleFrames = 1;
|
||||
this.width = SceneManager.stage.stageWidth * 0.8;
|
||||
this.width = Core.graphicsDevice.viewport.width * 0.8;
|
||||
|
||||
es.Core.emitter.addObserver(CoreEvents.GraphicsDeviceReset, this.onGraphicsDeviceReset, this);
|
||||
this.onGraphicsDeviceReset();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,26 @@
|
||||
module es {
|
||||
export class GlobalManager {
|
||||
public static globalManagers: GlobalManager[] = [];
|
||||
private _enabled: boolean;
|
||||
|
||||
/**
|
||||
* 如果true则启用了GlobalManager。
|
||||
* 状态的改变会导致调用OnEnabled/OnDisable
|
||||
*/
|
||||
public get enabled(){
|
||||
return this._enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* 如果true则启用了GlobalManager。
|
||||
* 状态的改变会导致调用OnEnabled/OnDisable
|
||||
* @param value
|
||||
*/
|
||||
public set enabled(value: boolean){
|
||||
this.setEnabled(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 启用/禁用这个GlobalManager
|
||||
* @param isEnabled
|
||||
*/
|
||||
public setEnabled(isEnabled: boolean){
|
||||
if (this._enabled != isEnabled){
|
||||
this._enabled = isEnabled;
|
||||
@@ -19,30 +31,21 @@ module es {
|
||||
}
|
||||
}
|
||||
}
|
||||
public _enabled: boolean;
|
||||
|
||||
/**
|
||||
* 此GlobalManager启用时调用
|
||||
*/
|
||||
public onEnabled(){}
|
||||
|
||||
/**
|
||||
* 此GlobalManager禁用时调用
|
||||
*/
|
||||
public onDisabled(){}
|
||||
|
||||
/**
|
||||
* 在frame .update之前调用每一帧
|
||||
*/
|
||||
public update(){}
|
||||
|
||||
public static registerGlobalManager(manager: GlobalManager){
|
||||
this.globalManagers.push(manager);
|
||||
manager.enabled = true;
|
||||
}
|
||||
|
||||
public static unregisterGlobalManager(manager: GlobalManager){
|
||||
this.globalManagers.remove(manager);
|
||||
manager.enabled = false;
|
||||
}
|
||||
|
||||
public static getGlobalManager<T extends GlobalManager>(type){
|
||||
for (let i = 0; i < this.globalManagers.length; i ++){
|
||||
if (this.globalManagers[i] instanceof type)
|
||||
return this.globalManagers[i] as T;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ module es {
|
||||
|
||||
export class Input {
|
||||
private static _init: boolean = false;
|
||||
private static _stage: egret.Stage;
|
||||
private static _previousTouchState: TouchState = new TouchState();
|
||||
private static _gameTouchs: TouchState[] = [];
|
||||
private static _resolutionOffset: Vector2 = new Vector2();
|
||||
@@ -33,13 +32,13 @@ module es {
|
||||
}
|
||||
/** 获取最大触摸数 */
|
||||
public static get maxSupportedTouch(){
|
||||
return this._stage.maxTouches;
|
||||
return Core._instance.stage.maxTouches;
|
||||
}
|
||||
/**
|
||||
* 设置最大触摸数
|
||||
*/
|
||||
public static set maxSupportedTouch(value: number){
|
||||
this._stage.maxTouches = value;
|
||||
Core._instance.stage.maxTouches = value;
|
||||
this.initTouchCache();
|
||||
}
|
||||
/** 获取缩放值 默认为1 */
|
||||
@@ -68,17 +67,16 @@ module es {
|
||||
return delta;
|
||||
}
|
||||
|
||||
public static initialize(stage: egret.Stage){
|
||||
public static initialize(){
|
||||
if (this._init)
|
||||
return;
|
||||
|
||||
this._init = true;
|
||||
this._stage = stage;
|
||||
this._stage.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.touchBegin, this);
|
||||
this._stage.addEventListener(egret.TouchEvent.TOUCH_MOVE, this.touchMove, this);
|
||||
this._stage.addEventListener(egret.TouchEvent.TOUCH_END, this.touchEnd, this);
|
||||
this._stage.addEventListener(egret.TouchEvent.TOUCH_CANCEL, this.touchEnd, this);
|
||||
this._stage.addEventListener(egret.TouchEvent.TOUCH_RELEASE_OUTSIDE, this.touchEnd, this);
|
||||
Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.touchBegin, this);
|
||||
Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_MOVE, this.touchMove, this);
|
||||
Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_END, this.touchEnd, this);
|
||||
Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_CANCEL, this.touchEnd, this);
|
||||
Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_RELEASE_OUTSIDE, this.touchEnd, this);
|
||||
|
||||
this.initTouchCache();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user