SceneManager更改为Core继承egret.DisplayContainer
This commit is contained in:
Vendored
+39
-33
@@ -246,9 +246,40 @@ declare module es {
|
|||||||
clone(): Component;
|
clone(): Component;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
declare module es {
|
||||||
|
class Core extends egret.DisplayObjectContainer {
|
||||||
|
static activeSceneChanged: Function;
|
||||||
|
static emitter: Emitter<CoreEvents>;
|
||||||
|
static graphicsDevice: GraphicsDevice;
|
||||||
|
static content: ContentManager;
|
||||||
|
static readonly Instance: Core;
|
||||||
|
static _instance: Core;
|
||||||
|
_scene: Scene;
|
||||||
|
_nextScene: Scene;
|
||||||
|
_sceneTransition: SceneTransition;
|
||||||
|
_globalManagers: GlobalManager[];
|
||||||
|
static scene: Scene;
|
||||||
|
constructor();
|
||||||
|
onOrientationChanged(): void;
|
||||||
|
protected onGraphicsDeviceReset(): void;
|
||||||
|
protected initialize(): void;
|
||||||
|
protected update(): void;
|
||||||
|
draw(): Promise<void>;
|
||||||
|
startDebugUpdate(): void;
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
declare module es {
|
declare module es {
|
||||||
enum CoreEvents {
|
enum CoreEvents {
|
||||||
SceneChanged = 0
|
GraphicsDeviceReset = 0,
|
||||||
|
SceneChanged = 1,
|
||||||
|
OrientationChanged = 2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
declare module es {
|
declare module es {
|
||||||
@@ -340,30 +371,6 @@ declare module es {
|
|||||||
getEntityProcessor<T extends EntitySystem>(): T;
|
getEntityProcessor<T extends EntitySystem>(): T;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
declare module es {
|
|
||||||
class SceneManager {
|
|
||||||
private static _scene;
|
|
||||||
private static _nextScene;
|
|
||||||
static sceneTransition: SceneTransition;
|
|
||||||
static stage: egret.Stage;
|
|
||||||
static activeSceneChanged: Function;
|
|
||||||
static emitter: Emitter<CoreEvents>;
|
|
||||||
static content: ContentManager;
|
|
||||||
private static _instnace;
|
|
||||||
private static timerRuler;
|
|
||||||
static readonly Instance: SceneManager;
|
|
||||||
constructor(stage: egret.Stage);
|
|
||||||
static scene: Scene;
|
|
||||||
static initialize(stage: egret.Stage): void;
|
|
||||||
static update(): void;
|
|
||||||
static render(): void;
|
|
||||||
static startSceneTransition<T extends SceneTransition>(sceneTransition: T): T;
|
|
||||||
static registerActiveSceneChanged(current: Scene, next: Scene): void;
|
|
||||||
onSceneChanged(): void;
|
|
||||||
private static startDebugUpdate;
|
|
||||||
private static endDebugUpdate;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
declare module transform {
|
declare module transform {
|
||||||
enum Component {
|
enum Component {
|
||||||
position = 0,
|
position = 0,
|
||||||
@@ -942,9 +949,11 @@ declare module es {
|
|||||||
}
|
}
|
||||||
declare module es {
|
declare module es {
|
||||||
class GraphicsDevice {
|
class GraphicsDevice {
|
||||||
private viewport;
|
private _viewport;
|
||||||
|
readonly viewport: Viewport;
|
||||||
graphicsCapabilities: GraphicsCapabilities;
|
graphicsCapabilities: GraphicsCapabilities;
|
||||||
constructor();
|
constructor();
|
||||||
|
private setup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
declare module es {
|
declare module es {
|
||||||
@@ -955,6 +964,8 @@ declare module es {
|
|||||||
private _height;
|
private _height;
|
||||||
private _minDepth;
|
private _minDepth;
|
||||||
private _maxDepth;
|
private _maxDepth;
|
||||||
|
height: number;
|
||||||
|
width: number;
|
||||||
readonly aspectRatio: number;
|
readonly aspectRatio: number;
|
||||||
bounds: Rectangle;
|
bounds: Rectangle;
|
||||||
constructor(x: number, y: number, width: number, height: number);
|
constructor(x: number, y: number, width: number, height: number);
|
||||||
@@ -1398,16 +1409,12 @@ declare module es {
|
|||||||
}
|
}
|
||||||
declare module es {
|
declare module es {
|
||||||
class GlobalManager {
|
class GlobalManager {
|
||||||
static globalManagers: GlobalManager[];
|
|
||||||
private _enabled;
|
|
||||||
enabled: boolean;
|
enabled: boolean;
|
||||||
setEnabled(isEnabled: boolean): void;
|
setEnabled(isEnabled: boolean): void;
|
||||||
|
_enabled: boolean;
|
||||||
onEnabled(): void;
|
onEnabled(): void;
|
||||||
onDisabled(): void;
|
onDisabled(): void;
|
||||||
update(): void;
|
update(): void;
|
||||||
static registerGlobalManager(manager: GlobalManager): void;
|
|
||||||
static unregisterGlobalManager(manager: GlobalManager): void;
|
|
||||||
static getGlobalManager<T extends GlobalManager>(type: any): T;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
declare module es {
|
declare module es {
|
||||||
@@ -1421,7 +1428,6 @@ declare module es {
|
|||||||
}
|
}
|
||||||
class Input {
|
class Input {
|
||||||
private static _init;
|
private static _init;
|
||||||
private static _stage;
|
|
||||||
private static _previousTouchState;
|
private static _previousTouchState;
|
||||||
private static _gameTouchs;
|
private static _gameTouchs;
|
||||||
private static _resolutionOffset;
|
private static _resolutionOffset;
|
||||||
@@ -1434,7 +1440,7 @@ declare module es {
|
|||||||
static readonly totalTouchCount: number;
|
static readonly totalTouchCount: number;
|
||||||
static readonly gameTouchs: TouchState[];
|
static readonly gameTouchs: TouchState[];
|
||||||
static readonly touchPositionDelta: Vector2;
|
static readonly touchPositionDelta: Vector2;
|
||||||
static initialize(stage: egret.Stage): void;
|
static initialize(): void;
|
||||||
private static initTouchCache;
|
private static initTouchCache;
|
||||||
private static touchBegin;
|
private static touchBegin;
|
||||||
private static touchMove;
|
private static touchMove;
|
||||||
|
|||||||
+216
-170
@@ -955,8 +955,8 @@ var es;
|
|||||||
Debug.render = function () {
|
Debug.render = function () {
|
||||||
if (this._debugDrawItems.length > 0) {
|
if (this._debugDrawItems.length > 0) {
|
||||||
var debugShape = new egret.Shape();
|
var debugShape = new egret.Shape();
|
||||||
if (es.SceneManager.scene) {
|
if (es.Core.scene) {
|
||||||
es.SceneManager.scene.addChild(debugShape);
|
es.Core.scene.addChild(debugShape);
|
||||||
}
|
}
|
||||||
for (var i = this._debugDrawItems.length - 1; i >= 0; i--) {
|
for (var i = this._debugDrawItems.length - 1; i >= 0; i--) {
|
||||||
var item = this._debugDrawItems[i];
|
var item = this._debugDrawItems[i];
|
||||||
@@ -1097,10 +1097,167 @@ var es;
|
|||||||
es.Component = Component;
|
es.Component = Component;
|
||||||
})(es || (es = {}));
|
})(es || (es = {}));
|
||||||
var es;
|
var es;
|
||||||
|
(function (es) {
|
||||||
|
var Core = (function (_super) {
|
||||||
|
__extends(Core, _super);
|
||||||
|
function Core() {
|
||||||
|
var _this = _super.call(this) || this;
|
||||||
|
_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);
|
||||||
|
return _this;
|
||||||
|
}
|
||||||
|
Object.defineProperty(Core, "Instance", {
|
||||||
|
get: function () {
|
||||||
|
return this._instance;
|
||||||
|
},
|
||||||
|
enumerable: true,
|
||||||
|
configurable: true
|
||||||
|
});
|
||||||
|
Object.defineProperty(Core, "scene", {
|
||||||
|
get: function () {
|
||||||
|
return this._instance._scene;
|
||||||
|
},
|
||||||
|
set: function (value) {
|
||||||
|
if (!value) {
|
||||||
|
console.error("场景不能为空");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this._instance._scene == null) {
|
||||||
|
this._instance._scene = value;
|
||||||
|
this._instance._scene.begin();
|
||||||
|
Core.Instance.onSceneChanged();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this._instance._nextScene = value;
|
||||||
|
}
|
||||||
|
this.registerActiveSceneChanged(this._instance._scene, this._instance._nextScene);
|
||||||
|
},
|
||||||
|
enumerable: true,
|
||||||
|
configurable: true
|
||||||
|
});
|
||||||
|
Core.prototype.onOrientationChanged = function () {
|
||||||
|
Core.emitter.emit(es.CoreEvents.OrientationChanged);
|
||||||
|
};
|
||||||
|
Core.prototype.onGraphicsDeviceReset = function () {
|
||||||
|
Core.emitter.emit(es.CoreEvents.GraphicsDeviceReset);
|
||||||
|
};
|
||||||
|
Core.prototype.initialize = function () {
|
||||||
|
};
|
||||||
|
Core.prototype.update = function () {
|
||||||
|
this.startDebugUpdate();
|
||||||
|
es.Time.update(egret.getTimer());
|
||||||
|
if (this._scene) {
|
||||||
|
for (var i = this._globalManagers.length - 1; i >= 0; i--) {
|
||||||
|
if (this._globalManagers[i].enabled)
|
||||||
|
this._globalManagers[i].update();
|
||||||
|
}
|
||||||
|
if (!this._sceneTransition ||
|
||||||
|
(this._sceneTransition && (!this._sceneTransition.loadsNewScene || this._sceneTransition.isNewSceneLoaded))) {
|
||||||
|
this._scene.update();
|
||||||
|
}
|
||||||
|
if (this._nextScene) {
|
||||||
|
this._scene.end();
|
||||||
|
this._scene = this._nextScene;
|
||||||
|
this._nextScene = null;
|
||||||
|
this.onSceneChanged();
|
||||||
|
this._scene.begin();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.endDebugUpdate();
|
||||||
|
};
|
||||||
|
Core.prototype.draw = function () {
|
||||||
|
return __awaiter(this, void 0, void 0, function () {
|
||||||
|
return __generator(this, function (_a) {
|
||||||
|
switch (_a.label) {
|
||||||
|
case 0:
|
||||||
|
if (!this._sceneTransition) return [3, 4];
|
||||||
|
this._sceneTransition.preRender();
|
||||||
|
if (!(this._scene && !this._sceneTransition.hasPreviousSceneRender)) return [3, 2];
|
||||||
|
this._scene.render();
|
||||||
|
this._scene.postRender();
|
||||||
|
return [4, this._sceneTransition.onBeginTransition()];
|
||||||
|
case 1:
|
||||||
|
_a.sent();
|
||||||
|
return [3, 3];
|
||||||
|
case 2:
|
||||||
|
if (this._sceneTransition) {
|
||||||
|
if (this._scene && this._sceneTransition.isNewSceneLoaded) {
|
||||||
|
this._scene.render();
|
||||||
|
this._scene.postRender();
|
||||||
|
}
|
||||||
|
this._sceneTransition.render();
|
||||||
|
}
|
||||||
|
_a.label = 3;
|
||||||
|
case 3: return [3, 5];
|
||||||
|
case 4:
|
||||||
|
if (this._scene) {
|
||||||
|
this._scene.render();
|
||||||
|
es.Debug.render();
|
||||||
|
this._scene.postRender();
|
||||||
|
}
|
||||||
|
_a.label = 5;
|
||||||
|
case 5: return [2];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
Core.prototype.startDebugUpdate = function () {
|
||||||
|
es.TimeRuler.Instance.startFrame();
|
||||||
|
es.TimeRuler.Instance.beginMark("update", 0x00FF00);
|
||||||
|
};
|
||||||
|
Core.prototype.endDebugUpdate = function () {
|
||||||
|
es.TimeRuler.Instance.endMark("update");
|
||||||
|
};
|
||||||
|
Core.prototype.onSceneChanged = function () {
|
||||||
|
Core.emitter.emit(es.CoreEvents.SceneChanged);
|
||||||
|
es.Time.sceneChanged();
|
||||||
|
};
|
||||||
|
Core.startSceneTransition = function (sceneTransition) {
|
||||||
|
if (this._instance._sceneTransition) {
|
||||||
|
console.warn("在前一个场景完成之前,不能开始一个新的场景转换。");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
Core.unregisterGlobalManager = function (manager) {
|
||||||
|
this._instance._globalManagers.remove(manager);
|
||||||
|
manager.enabled = false;
|
||||||
|
};
|
||||||
|
Core.getGlobalManager = function (type) {
|
||||||
|
for (var i = 0; i < this._instance._globalManagers.length; i++) {
|
||||||
|
if (this._instance._globalManagers[i] instanceof type)
|
||||||
|
return this._instance._globalManagers[i];
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
return Core;
|
||||||
|
}(egret.DisplayObjectContainer));
|
||||||
|
es.Core = Core;
|
||||||
|
})(es || (es = {}));
|
||||||
|
var es;
|
||||||
(function (es) {
|
(function (es) {
|
||||||
var CoreEvents;
|
var CoreEvents;
|
||||||
(function (CoreEvents) {
|
(function (CoreEvents) {
|
||||||
CoreEvents[CoreEvents["SceneChanged"] = 0] = "SceneChanged";
|
CoreEvents[CoreEvents["GraphicsDeviceReset"] = 0] = "GraphicsDeviceReset";
|
||||||
|
CoreEvents[CoreEvents["SceneChanged"] = 1] = "SceneChanged";
|
||||||
|
CoreEvents[CoreEvents["OrientationChanged"] = 2] = "OrientationChanged";
|
||||||
})(CoreEvents = es.CoreEvents || (es.CoreEvents = {}));
|
})(CoreEvents = es.CoreEvents || (es.CoreEvents = {}));
|
||||||
})(es || (es = {}));
|
})(es || (es = {}));
|
||||||
var es;
|
var es;
|
||||||
@@ -1347,8 +1504,6 @@ var es;
|
|||||||
_this.renderableComponents = new es.RenderableComponentList();
|
_this.renderableComponents = new es.RenderableComponentList();
|
||||||
_this.content = new es.ContentManager();
|
_this.content = new es.ContentManager();
|
||||||
_this.entityProcessors = new es.EntityProcessorList();
|
_this.entityProcessors = new es.EntityProcessorList();
|
||||||
_this.width = es.SceneManager.stage.stageWidth;
|
|
||||||
_this.height = es.SceneManager.stage.stageHeight;
|
|
||||||
_this.initialize();
|
_this.initialize();
|
||||||
return _this;
|
return _this;
|
||||||
}
|
}
|
||||||
@@ -1369,12 +1524,6 @@ var es;
|
|||||||
Scene.prototype.begin = function () {
|
Scene.prototype.begin = function () {
|
||||||
return __awaiter(this, void 0, void 0, function () {
|
return __awaiter(this, void 0, void 0, function () {
|
||||||
return __generator(this, function (_a) {
|
return __generator(this, function (_a) {
|
||||||
if (es.SceneManager.sceneTransition) {
|
|
||||||
es.SceneManager.stage.addChildAt(this, es.SceneManager.stage.numChildren - 1);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
es.SceneManager.stage.addChild(this);
|
|
||||||
}
|
|
||||||
if (this._renderers.length == 0) {
|
if (this._renderers.length == 0) {
|
||||||
this.addRenderer(new es.DefaultRenderer());
|
this.addRenderer(new es.DefaultRenderer());
|
||||||
console.warn("场景开始时没有渲染器 自动添加DefaultRenderer以保证能够正常渲染");
|
console.warn("场景开始时没有渲染器 自动添加DefaultRenderer以保证能够正常渲染");
|
||||||
@@ -1528,120 +1677,6 @@ var es;
|
|||||||
}(egret.DisplayObjectContainer));
|
}(egret.DisplayObjectContainer));
|
||||||
es.Scene = Scene;
|
es.Scene = Scene;
|
||||||
})(es || (es = {}));
|
})(es || (es = {}));
|
||||||
var es;
|
|
||||||
(function (es) {
|
|
||||||
var SceneManager = (function () {
|
|
||||||
function SceneManager(stage) {
|
|
||||||
stage.addEventListener(egret.Event.ENTER_FRAME, SceneManager.update, this);
|
|
||||||
SceneManager._instnace = this;
|
|
||||||
SceneManager.emitter = new es.Emitter();
|
|
||||||
SceneManager.content = new es.ContentManager();
|
|
||||||
SceneManager.stage = stage;
|
|
||||||
SceneManager.initialize(stage);
|
|
||||||
SceneManager.timerRuler = new es.TimeRuler();
|
|
||||||
}
|
|
||||||
Object.defineProperty(SceneManager, "Instance", {
|
|
||||||
get: function () {
|
|
||||||
return this._instnace;
|
|
||||||
},
|
|
||||||
enumerable: true,
|
|
||||||
configurable: true
|
|
||||||
});
|
|
||||||
Object.defineProperty(SceneManager, "scene", {
|
|
||||||
get: function () {
|
|
||||||
return this._scene;
|
|
||||||
},
|
|
||||||
set: function (value) {
|
|
||||||
if (!value)
|
|
||||||
throw new Error("场景不能为空");
|
|
||||||
if (this._scene == null) {
|
|
||||||
this._scene = value;
|
|
||||||
this._scene.begin();
|
|
||||||
SceneManager.Instance.onSceneChanged();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
this._nextScene = value;
|
|
||||||
}
|
|
||||||
this.registerActiveSceneChanged(this._scene, this._nextScene);
|
|
||||||
},
|
|
||||||
enumerable: true,
|
|
||||||
configurable: true
|
|
||||||
});
|
|
||||||
SceneManager.initialize = function (stage) {
|
|
||||||
es.Input.initialize(stage);
|
|
||||||
};
|
|
||||||
SceneManager.update = function () {
|
|
||||||
SceneManager.startDebugUpdate();
|
|
||||||
es.Time.update(egret.getTimer());
|
|
||||||
if (SceneManager._scene) {
|
|
||||||
for (var i = es.GlobalManager.globalManagers.length - 1; i >= 0; i--) {
|
|
||||||
if (es.GlobalManager.globalManagers[i].enabled)
|
|
||||||
es.GlobalManager.globalManagers[i].update();
|
|
||||||
}
|
|
||||||
if (!SceneManager.sceneTransition ||
|
|
||||||
(SceneManager.sceneTransition && (!SceneManager.sceneTransition.loadsNewScene || SceneManager.sceneTransition.isNewSceneLoaded))) {
|
|
||||||
SceneManager._scene.update();
|
|
||||||
}
|
|
||||||
if (SceneManager._nextScene) {
|
|
||||||
SceneManager._scene.end();
|
|
||||||
SceneManager._scene = SceneManager._nextScene;
|
|
||||||
SceneManager._nextScene = null;
|
|
||||||
SceneManager._instnace.onSceneChanged();
|
|
||||||
SceneManager._scene.begin();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
SceneManager.endDebugUpdate();
|
|
||||||
SceneManager.render();
|
|
||||||
};
|
|
||||||
SceneManager.render = function () {
|
|
||||||
if (this.sceneTransition) {
|
|
||||||
this.sceneTransition.preRender();
|
|
||||||
if (this._scene && !this.sceneTransition.hasPreviousSceneRender) {
|
|
||||||
this._scene.render();
|
|
||||||
this._scene.postRender();
|
|
||||||
this.sceneTransition.onBeginTransition();
|
|
||||||
}
|
|
||||||
else if (this.sceneTransition) {
|
|
||||||
if (this._scene && this.sceneTransition.isNewSceneLoaded) {
|
|
||||||
this._scene.render();
|
|
||||||
this._scene.postRender();
|
|
||||||
}
|
|
||||||
this.sceneTransition.render();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (this._scene) {
|
|
||||||
this._scene.render();
|
|
||||||
es.Debug.render();
|
|
||||||
this._scene.postRender();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
SceneManager.startSceneTransition = function (sceneTransition) {
|
|
||||||
if (this.sceneTransition) {
|
|
||||||
console.warn("在前一个场景完成之前,不能开始一个新的场景转换。");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.sceneTransition = sceneTransition;
|
|
||||||
return sceneTransition;
|
|
||||||
};
|
|
||||||
SceneManager.registerActiveSceneChanged = function (current, next) {
|
|
||||||
if (this.activeSceneChanged)
|
|
||||||
this.activeSceneChanged(current, next);
|
|
||||||
};
|
|
||||||
SceneManager.prototype.onSceneChanged = function () {
|
|
||||||
SceneManager.emitter.emit(es.CoreEvents.SceneChanged);
|
|
||||||
es.Time.sceneChanged();
|
|
||||||
};
|
|
||||||
SceneManager.startDebugUpdate = function () {
|
|
||||||
es.TimeRuler.Instance.startFrame();
|
|
||||||
es.TimeRuler.Instance.beginMark("update", 0x00FF00);
|
|
||||||
};
|
|
||||||
SceneManager.endDebugUpdate = function () {
|
|
||||||
es.TimeRuler.Instance.endMark("update");
|
|
||||||
};
|
|
||||||
return SceneManager;
|
|
||||||
}());
|
|
||||||
es.SceneManager = SceneManager;
|
|
||||||
})(es || (es = {}));
|
|
||||||
var transform;
|
var transform;
|
||||||
(function (transform) {
|
(function (transform) {
|
||||||
var Component;
|
var Component;
|
||||||
@@ -1851,10 +1886,10 @@ var es;
|
|||||||
this.updateMatrixes();
|
this.updateMatrixes();
|
||||||
if (this._areBoundsDirty) {
|
if (this._areBoundsDirty) {
|
||||||
var topLeft = this.screenToWorldPoint(new es.Vector2(this._inset.left, this._inset.top));
|
var topLeft = this.screenToWorldPoint(new es.Vector2(this._inset.left, this._inset.top));
|
||||||
var bottomRight = this.screenToWorldPoint(new es.Vector2(es.SceneManager.stage.stageWidth - this._inset.right, es.SceneManager.stage.stageHeight - this._inset.bottom));
|
var bottomRight = this.screenToWorldPoint(new es.Vector2(es.Core.graphicsDevice.viewport.width - this._inset.right, es.Core.graphicsDevice.viewport.height - this._inset.bottom));
|
||||||
if (this.entity.transform.rotation != 0) {
|
if (this.entity.transform.rotation != 0) {
|
||||||
var topRight = this.screenToWorldPoint(new es.Vector2(es.SceneManager.stage.stageWidth - this._inset.right, this._inset.top));
|
var topRight = this.screenToWorldPoint(new es.Vector2(es.Core.graphicsDevice.viewport.width - this._inset.right, this._inset.top));
|
||||||
var bottomLeft = this.screenToWorldPoint(new es.Vector2(this._inset.left, es.SceneManager.stage.stageHeight - this._inset.bottom));
|
var bottomLeft = this.screenToWorldPoint(new es.Vector2(this._inset.left, es.Core.graphicsDevice.viewport.height - this._inset.bottom));
|
||||||
var minX = Math.min(topLeft.x, bottomRight.x, topRight.x, bottomLeft.x);
|
var minX = Math.min(topLeft.x, bottomRight.x, topRight.x, bottomLeft.x);
|
||||||
var maxX = Math.max(topLeft.x, bottomRight.x, topRight.x, bottomLeft.x);
|
var maxX = Math.max(topLeft.x, bottomRight.x, topRight.x, bottomLeft.x);
|
||||||
var minY = Math.min(topLeft.y, bottomRight.y, topRight.y, bottomLeft.y);
|
var minY = Math.min(topLeft.y, bottomRight.y, topRight.y, bottomLeft.y);
|
||||||
@@ -2008,8 +2043,8 @@ var es;
|
|||||||
};
|
};
|
||||||
Camera.prototype.update = function () {
|
Camera.prototype.update = function () {
|
||||||
var halfScreen = es.Vector2.multiply(new es.Vector2(this.bounds.width, this.bounds.height), new es.Vector2(0.5));
|
var halfScreen = es.Vector2.multiply(new es.Vector2(this.bounds.width, this.bounds.height), new es.Vector2(0.5));
|
||||||
this._worldSpaceDeadZone.x = this.position.x - halfScreen.x * es.SceneManager.scene.scaleX + this.deadzone.x + this.focusOffset.x;
|
this._worldSpaceDeadZone.x = this.position.x - halfScreen.x * es.Core.scene.scaleX + this.deadzone.x + this.focusOffset.x;
|
||||||
this._worldSpaceDeadZone.y = this.position.y - halfScreen.y * es.SceneManager.scene.scaleY + this.deadzone.y + this.focusOffset.y;
|
this._worldSpaceDeadZone.y = this.position.y - halfScreen.y * es.Core.scene.scaleY + this.deadzone.y + this.focusOffset.y;
|
||||||
this._worldSpaceDeadZone.width = this.deadzone.width;
|
this._worldSpaceDeadZone.width = this.deadzone.width;
|
||||||
this._worldSpaceDeadZone.height = this.deadzone.height;
|
this._worldSpaceDeadZone.height = this.deadzone.height;
|
||||||
if (this._targetEntity)
|
if (this._targetEntity)
|
||||||
@@ -4021,7 +4056,7 @@ var es;
|
|||||||
var offsetY = Math.round(bitmapData.$offsetY);
|
var offsetY = Math.round(bitmapData.$offsetY);
|
||||||
var bitmapWidth = bitmapData.$bitmapWidth;
|
var bitmapWidth = bitmapData.$bitmapWidth;
|
||||||
var bitmapHeight = bitmapData.$bitmapHeight;
|
var bitmapHeight = bitmapData.$bitmapHeight;
|
||||||
var $TextureScaleFactor = es.SceneManager.stage.textureScaleFactor;
|
var $TextureScaleFactor = es.Core._instance.stage.textureScaleFactor;
|
||||||
this.sharedContext.drawImage(bitmapData.$bitmapData.source, bitmapData.$bitmapX + rect.x / $TextureScaleFactor, bitmapData.$bitmapY + rect.y / $TextureScaleFactor, bitmapWidth * rect.width / w, bitmapHeight * rect.height / h, offsetX, offsetY, rect.width, rect.height);
|
this.sharedContext.drawImage(bitmapData.$bitmapData.source, bitmapData.$bitmapX + rect.x / $TextureScaleFactor, bitmapData.$bitmapY + rect.y / $TextureScaleFactor, bitmapWidth * rect.width / w, bitmapHeight * rect.height / h, offsetX, offsetY, rect.width, rect.height);
|
||||||
return surface;
|
return surface;
|
||||||
}
|
}
|
||||||
@@ -4300,9 +4335,20 @@ var es;
|
|||||||
(function (es) {
|
(function (es) {
|
||||||
var GraphicsDevice = (function () {
|
var GraphicsDevice = (function () {
|
||||||
function GraphicsDevice() {
|
function GraphicsDevice() {
|
||||||
|
this.setup();
|
||||||
this.graphicsCapabilities = new es.GraphicsCapabilities();
|
this.graphicsCapabilities = new es.GraphicsCapabilities();
|
||||||
this.graphicsCapabilities.initialize(this);
|
this.graphicsCapabilities.initialize(this);
|
||||||
}
|
}
|
||||||
|
Object.defineProperty(GraphicsDevice.prototype, "viewport", {
|
||||||
|
get: function () {
|
||||||
|
return this._viewport;
|
||||||
|
},
|
||||||
|
enumerable: true,
|
||||||
|
configurable: true
|
||||||
|
});
|
||||||
|
GraphicsDevice.prototype.setup = function () {
|
||||||
|
this._viewport = new es.Viewport(0, 0, es.Core._instance.stage.stageWidth, es.Core._instance.stage.stageHeight);
|
||||||
|
};
|
||||||
return GraphicsDevice;
|
return GraphicsDevice;
|
||||||
}());
|
}());
|
||||||
es.GraphicsDevice = GraphicsDevice;
|
es.GraphicsDevice = GraphicsDevice;
|
||||||
@@ -4318,6 +4364,26 @@ var es;
|
|||||||
this._minDepth = 0;
|
this._minDepth = 0;
|
||||||
this._maxDepth = 1;
|
this._maxDepth = 1;
|
||||||
}
|
}
|
||||||
|
Object.defineProperty(Viewport.prototype, "height", {
|
||||||
|
get: function () {
|
||||||
|
return this._height;
|
||||||
|
},
|
||||||
|
set: function (value) {
|
||||||
|
this._height = value;
|
||||||
|
},
|
||||||
|
enumerable: true,
|
||||||
|
configurable: true
|
||||||
|
});
|
||||||
|
Object.defineProperty(Viewport.prototype, "width", {
|
||||||
|
get: function () {
|
||||||
|
return this._width;
|
||||||
|
},
|
||||||
|
set: function (value) {
|
||||||
|
this._width = value;
|
||||||
|
},
|
||||||
|
enumerable: true,
|
||||||
|
configurable: true
|
||||||
|
});
|
||||||
Object.defineProperty(Viewport.prototype, "aspectRatio", {
|
Object.defineProperty(Viewport.prototype, "aspectRatio", {
|
||||||
get: function () {
|
get: function () {
|
||||||
if ((this._height != 0) && (this._width != 0))
|
if ((this._height != 0) && (this._width != 0))
|
||||||
@@ -4350,8 +4416,8 @@ var es;
|
|||||||
__extends(GaussianBlurEffect, _super);
|
__extends(GaussianBlurEffect, _super);
|
||||||
function GaussianBlurEffect() {
|
function GaussianBlurEffect() {
|
||||||
return _super.call(this, es.PostProcessor.default_vert, GaussianBlurEffect.blur_frag, {
|
return _super.call(this, es.PostProcessor.default_vert, GaussianBlurEffect.blur_frag, {
|
||||||
screenWidth: es.SceneManager.stage.stageWidth,
|
screenWidth: es.Core.graphicsDevice.viewport.width,
|
||||||
screenHeight: es.SceneManager.stage.stageHeight
|
screenHeight: es.Core.graphicsDevice.viewport.height
|
||||||
}) || this;
|
}) || this;
|
||||||
}
|
}
|
||||||
GaussianBlurEffect.blur_frag = "precision mediump float;\n" +
|
GaussianBlurEffect.blur_frag = "precision mediump float;\n" +
|
||||||
@@ -4435,7 +4501,7 @@ var es;
|
|||||||
this.scene = scene;
|
this.scene = scene;
|
||||||
this.shape = new egret.Shape();
|
this.shape = new egret.Shape();
|
||||||
this.shape.graphics.beginFill(0xFFFFFF, 1);
|
this.shape.graphics.beginFill(0xFFFFFF, 1);
|
||||||
this.shape.graphics.drawRect(0, 0, es.SceneManager.stage.stageWidth, es.SceneManager.stage.stageHeight);
|
this.shape.graphics.drawRect(0, 0, es.Core.graphicsDevice.viewport.width, es.Core.graphicsDevice.viewport.height);
|
||||||
this.shape.graphics.endFill();
|
this.shape.graphics.endFill();
|
||||||
scene.addChild(this.shape);
|
scene.addChild(this.shape);
|
||||||
};
|
};
|
||||||
@@ -4614,7 +4680,7 @@ var es;
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
SceneTransition.prototype.transitionComplete = function () {
|
SceneTransition.prototype.transitionComplete = function () {
|
||||||
es.SceneManager.sceneTransition = null;
|
es.Core._instance._sceneTransition = null;
|
||||||
if (this.onTransitionCompleted) {
|
if (this.onTransitionCompleted) {
|
||||||
this.onTransitionCompleted();
|
this.onTransitionCompleted();
|
||||||
}
|
}
|
||||||
@@ -4630,7 +4696,7 @@ var es;
|
|||||||
if (!this.loadsNewScene) {
|
if (!this.loadsNewScene) {
|
||||||
this.isNewSceneLoaded = true;
|
this.isNewSceneLoaded = true;
|
||||||
}
|
}
|
||||||
_a = es.SceneManager;
|
_a = es.Core;
|
||||||
return [4, this.sceneLoadAction()];
|
return [4, this.sceneLoadAction()];
|
||||||
case 1:
|
case 1:
|
||||||
_a.scene = _b.sent();
|
_a.scene = _b.sent();
|
||||||
@@ -4673,9 +4739,8 @@ var es;
|
|||||||
var _this = this;
|
var _this = this;
|
||||||
return __generator(this, function (_a) {
|
return __generator(this, function (_a) {
|
||||||
this._mask.graphics.beginFill(this.fadeToColor, 1);
|
this._mask.graphics.beginFill(this.fadeToColor, 1);
|
||||||
this._mask.graphics.drawRect(0, 0, es.SceneManager.stage.stageWidth, es.SceneManager.stage.stageHeight);
|
this._mask.graphics.drawRect(0, 0, es.Core.graphicsDevice.viewport.width, es.Core.graphicsDevice.viewport.height);
|
||||||
this._mask.graphics.endFill();
|
this._mask.graphics.endFill();
|
||||||
es.SceneManager.stage.addChild(this._mask);
|
|
||||||
egret.Tween.get(this).to({ _alpha: 1 }, this.fadeOutDuration * 1000, this.fadeEaseType)
|
egret.Tween.get(this).to({ _alpha: 1 }, this.fadeOutDuration * 1000, this.fadeEaseType)
|
||||||
.call(function () { return __awaiter(_this, void 0, void 0, function () {
|
.call(function () { return __awaiter(_this, void 0, void 0, function () {
|
||||||
return __generator(this, function (_a) {
|
return __generator(this, function (_a) {
|
||||||
@@ -4689,7 +4754,6 @@ var es;
|
|||||||
}); }).wait(this.delayBeforeFadeInDuration).call(function () {
|
}); }).wait(this.delayBeforeFadeInDuration).call(function () {
|
||||||
egret.Tween.get(_this).to({ _alpha: 0 }, _this.fadeOutDuration * 1000, _this.fadeEaseType).call(function () {
|
egret.Tween.get(_this).to({ _alpha: 0 }, _this.fadeOutDuration * 1000, _this.fadeEaseType).call(function () {
|
||||||
_this.transitionComplete();
|
_this.transitionComplete();
|
||||||
es.SceneManager.stage.removeChild(_this._mask);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return [2];
|
return [2];
|
||||||
@@ -4699,7 +4763,7 @@ var es;
|
|||||||
FadeTransition.prototype.render = function () {
|
FadeTransition.prototype.render = function () {
|
||||||
this._mask.graphics.clear();
|
this._mask.graphics.clear();
|
||||||
this._mask.graphics.beginFill(this.fadeToColor, this._alpha);
|
this._mask.graphics.beginFill(this.fadeToColor, this._alpha);
|
||||||
this._mask.graphics.drawRect(0, 0, es.SceneManager.stage.stageWidth, es.SceneManager.stage.stageHeight);
|
this._mask.graphics.drawRect(0, 0, es.Core.graphicsDevice.viewport.width, es.Core.graphicsDevice.viewport.height);
|
||||||
this._mask.graphics.endFill();
|
this._mask.graphics.endFill();
|
||||||
};
|
};
|
||||||
return FadeTransition;
|
return FadeTransition;
|
||||||
@@ -4744,10 +4808,9 @@ var es;
|
|||||||
});
|
});
|
||||||
_this._mask = new egret.Shape();
|
_this._mask = new egret.Shape();
|
||||||
_this._mask.graphics.beginFill(0xFFFFFF, 1);
|
_this._mask.graphics.beginFill(0xFFFFFF, 1);
|
||||||
_this._mask.graphics.drawRect(0, 0, es.SceneManager.stage.stageWidth, es.SceneManager.stage.stageHeight);
|
_this._mask.graphics.drawRect(0, 0, es.Core.graphicsDevice.viewport.width, es.Core.graphicsDevice.viewport.height);
|
||||||
_this._mask.graphics.endFill();
|
_this._mask.graphics.endFill();
|
||||||
_this._mask.filters = [_this._windEffect];
|
_this._mask.filters = [_this._windEffect];
|
||||||
es.SceneManager.stage.addChild(_this._mask);
|
|
||||||
return _this;
|
return _this;
|
||||||
}
|
}
|
||||||
Object.defineProperty(WindTransition.prototype, "windSegments", {
|
Object.defineProperty(WindTransition.prototype, "windSegments", {
|
||||||
@@ -4774,7 +4837,6 @@ var es;
|
|||||||
case 1:
|
case 1:
|
||||||
_a.sent();
|
_a.sent();
|
||||||
this.transitionComplete();
|
this.transitionComplete();
|
||||||
es.SceneManager.stage.removeChild(this._mask);
|
|
||||||
return [2];
|
return [2];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -6625,22 +6687,6 @@ var es;
|
|||||||
GlobalManager.prototype.onEnabled = function () { };
|
GlobalManager.prototype.onEnabled = function () { };
|
||||||
GlobalManager.prototype.onDisabled = function () { };
|
GlobalManager.prototype.onDisabled = function () { };
|
||||||
GlobalManager.prototype.update = function () { };
|
GlobalManager.prototype.update = function () { };
|
||||||
GlobalManager.registerGlobalManager = function (manager) {
|
|
||||||
this.globalManagers.push(manager);
|
|
||||||
manager.enabled = true;
|
|
||||||
};
|
|
||||||
GlobalManager.unregisterGlobalManager = function (manager) {
|
|
||||||
this.globalManagers.remove(manager);
|
|
||||||
manager.enabled = false;
|
|
||||||
};
|
|
||||||
GlobalManager.getGlobalManager = function (type) {
|
|
||||||
for (var i = 0; i < this.globalManagers.length; i++) {
|
|
||||||
if (this.globalManagers[i] instanceof type)
|
|
||||||
return this.globalManagers[i];
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
GlobalManager.globalManagers = [];
|
|
||||||
return GlobalManager;
|
return GlobalManager;
|
||||||
}());
|
}());
|
||||||
es.GlobalManager = GlobalManager;
|
es.GlobalManager = GlobalManager;
|
||||||
@@ -6684,10 +6730,10 @@ var es;
|
|||||||
});
|
});
|
||||||
Object.defineProperty(Input, "maxSupportedTouch", {
|
Object.defineProperty(Input, "maxSupportedTouch", {
|
||||||
get: function () {
|
get: function () {
|
||||||
return this._stage.maxTouches;
|
return es.Core._instance.stage.maxTouches;
|
||||||
},
|
},
|
||||||
set: function (value) {
|
set: function (value) {
|
||||||
this._stage.maxTouches = value;
|
es.Core._instance.stage.maxTouches = value;
|
||||||
this.initTouchCache();
|
this.initTouchCache();
|
||||||
},
|
},
|
||||||
enumerable: true,
|
enumerable: true,
|
||||||
@@ -6725,16 +6771,15 @@ var es;
|
|||||||
enumerable: true,
|
enumerable: true,
|
||||||
configurable: true
|
configurable: true
|
||||||
});
|
});
|
||||||
Input.initialize = function (stage) {
|
Input.initialize = function () {
|
||||||
if (this._init)
|
if (this._init)
|
||||||
return;
|
return;
|
||||||
this._init = true;
|
this._init = true;
|
||||||
this._stage = stage;
|
es.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.touchBegin, this);
|
||||||
this._stage.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.touchBegin, this);
|
es.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_MOVE, this.touchMove, this);
|
||||||
this._stage.addEventListener(egret.TouchEvent.TOUCH_MOVE, this.touchMove, this);
|
es.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_END, this.touchEnd, this);
|
||||||
this._stage.addEventListener(egret.TouchEvent.TOUCH_END, this.touchEnd, this);
|
es.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_CANCEL, this.touchEnd, this);
|
||||||
this._stage.addEventListener(egret.TouchEvent.TOUCH_CANCEL, this.touchEnd, this);
|
es.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_RELEASE_OUTSIDE, this.touchEnd, this);
|
||||||
this._stage.addEventListener(egret.TouchEvent.TOUCH_RELEASE_OUTSIDE, this.touchEnd, this);
|
|
||||||
this.initTouchCache();
|
this.initTouchCache();
|
||||||
};
|
};
|
||||||
Input.initTouchCache = function () {
|
Input.initTouchCache = function () {
|
||||||
@@ -7324,7 +7369,7 @@ var es;
|
|||||||
(function (es) {
|
(function (es) {
|
||||||
var Layout = (function () {
|
var Layout = (function () {
|
||||||
function Layout() {
|
function Layout() {
|
||||||
this.clientArea = new es.Rectangle(0, 0, es.SceneManager.stage.stageWidth, es.SceneManager.stage.stageHeight);
|
this.clientArea = new es.Rectangle(0, 0, es.Core.graphicsDevice.viewport.width, es.Core.graphicsDevice.viewport.height);
|
||||||
this.safeArea = this.clientArea;
|
this.safeArea = this.clientArea;
|
||||||
}
|
}
|
||||||
Layout.prototype.place = function (size, horizontalMargin, verticalMargine, alignment) {
|
Layout.prototype.place = function (size, horizontalMargin, verticalMargine, alignment) {
|
||||||
@@ -7530,7 +7575,8 @@ var es;
|
|||||||
for (var i = 0; i < this._logs.length; ++i)
|
for (var i = 0; i < this._logs.length; ++i)
|
||||||
this._logs[i] = new FrameLog();
|
this._logs[i] = new FrameLog();
|
||||||
this.sampleFrames = this.targetSampleFrames = 1;
|
this.sampleFrames = this.targetSampleFrames = 1;
|
||||||
this.width = es.SceneManager.stage.stageWidth * 0.8;
|
this.width = es.Core.graphicsDevice.viewport.width * 0.8;
|
||||||
|
es.Core.emitter.addObserver(es.CoreEvents.GraphicsDeviceReset, this.onGraphicsDeviceReset, this);
|
||||||
this.onGraphicsDeviceReset();
|
this.onGraphicsDeviceReset();
|
||||||
}
|
}
|
||||||
TimeRuler.prototype.onGraphicsDeviceReset = function () {
|
TimeRuler.prototype.onGraphicsDeviceReset = function () {
|
||||||
|
|||||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
+4
-1
@@ -28,7 +28,10 @@
|
|||||||
//////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
class Main extends eui.UILayer {
|
import SceneManager = es.SceneManager;
|
||||||
|
import Emitter = es.Emitter;
|
||||||
|
|
||||||
|
class Main extends SceneManager {
|
||||||
public static emitter: Emitter<CoreEmitterType>;
|
public static emitter: Emitter<CoreEmitterType>;
|
||||||
public static manager: SceneManager;
|
public static manager: SceneManager;
|
||||||
|
|
||||||
|
|||||||
Vendored
+39
-33
@@ -246,9 +246,40 @@ declare module es {
|
|||||||
clone(): Component;
|
clone(): Component;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
declare module es {
|
||||||
|
class Core extends egret.DisplayObjectContainer {
|
||||||
|
static activeSceneChanged: Function;
|
||||||
|
static emitter: Emitter<CoreEvents>;
|
||||||
|
static graphicsDevice: GraphicsDevice;
|
||||||
|
static content: ContentManager;
|
||||||
|
static readonly Instance: Core;
|
||||||
|
static _instance: Core;
|
||||||
|
_scene: Scene;
|
||||||
|
_nextScene: Scene;
|
||||||
|
_sceneTransition: SceneTransition;
|
||||||
|
_globalManagers: GlobalManager[];
|
||||||
|
static scene: Scene;
|
||||||
|
constructor();
|
||||||
|
onOrientationChanged(): void;
|
||||||
|
protected onGraphicsDeviceReset(): void;
|
||||||
|
protected initialize(): void;
|
||||||
|
protected update(): void;
|
||||||
|
draw(): Promise<void>;
|
||||||
|
startDebugUpdate(): void;
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
declare module es {
|
declare module es {
|
||||||
enum CoreEvents {
|
enum CoreEvents {
|
||||||
SceneChanged = 0
|
GraphicsDeviceReset = 0,
|
||||||
|
SceneChanged = 1,
|
||||||
|
OrientationChanged = 2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
declare module es {
|
declare module es {
|
||||||
@@ -340,30 +371,6 @@ declare module es {
|
|||||||
getEntityProcessor<T extends EntitySystem>(): T;
|
getEntityProcessor<T extends EntitySystem>(): T;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
declare module es {
|
|
||||||
class SceneManager {
|
|
||||||
private static _scene;
|
|
||||||
private static _nextScene;
|
|
||||||
static sceneTransition: SceneTransition;
|
|
||||||
static stage: egret.Stage;
|
|
||||||
static activeSceneChanged: Function;
|
|
||||||
static emitter: Emitter<CoreEvents>;
|
|
||||||
static content: ContentManager;
|
|
||||||
private static _instnace;
|
|
||||||
private static timerRuler;
|
|
||||||
static readonly Instance: SceneManager;
|
|
||||||
constructor(stage: egret.Stage);
|
|
||||||
static scene: Scene;
|
|
||||||
static initialize(stage: egret.Stage): void;
|
|
||||||
static update(): void;
|
|
||||||
static render(): void;
|
|
||||||
static startSceneTransition<T extends SceneTransition>(sceneTransition: T): T;
|
|
||||||
static registerActiveSceneChanged(current: Scene, next: Scene): void;
|
|
||||||
onSceneChanged(): void;
|
|
||||||
private static startDebugUpdate;
|
|
||||||
private static endDebugUpdate;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
declare module transform {
|
declare module transform {
|
||||||
enum Component {
|
enum Component {
|
||||||
position = 0,
|
position = 0,
|
||||||
@@ -942,9 +949,11 @@ declare module es {
|
|||||||
}
|
}
|
||||||
declare module es {
|
declare module es {
|
||||||
class GraphicsDevice {
|
class GraphicsDevice {
|
||||||
private viewport;
|
private _viewport;
|
||||||
|
readonly viewport: Viewport;
|
||||||
graphicsCapabilities: GraphicsCapabilities;
|
graphicsCapabilities: GraphicsCapabilities;
|
||||||
constructor();
|
constructor();
|
||||||
|
private setup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
declare module es {
|
declare module es {
|
||||||
@@ -955,6 +964,8 @@ declare module es {
|
|||||||
private _height;
|
private _height;
|
||||||
private _minDepth;
|
private _minDepth;
|
||||||
private _maxDepth;
|
private _maxDepth;
|
||||||
|
height: number;
|
||||||
|
width: number;
|
||||||
readonly aspectRatio: number;
|
readonly aspectRatio: number;
|
||||||
bounds: Rectangle;
|
bounds: Rectangle;
|
||||||
constructor(x: number, y: number, width: number, height: number);
|
constructor(x: number, y: number, width: number, height: number);
|
||||||
@@ -1398,16 +1409,12 @@ declare module es {
|
|||||||
}
|
}
|
||||||
declare module es {
|
declare module es {
|
||||||
class GlobalManager {
|
class GlobalManager {
|
||||||
static globalManagers: GlobalManager[];
|
|
||||||
private _enabled;
|
|
||||||
enabled: boolean;
|
enabled: boolean;
|
||||||
setEnabled(isEnabled: boolean): void;
|
setEnabled(isEnabled: boolean): void;
|
||||||
|
_enabled: boolean;
|
||||||
onEnabled(): void;
|
onEnabled(): void;
|
||||||
onDisabled(): void;
|
onDisabled(): void;
|
||||||
update(): void;
|
update(): void;
|
||||||
static registerGlobalManager(manager: GlobalManager): void;
|
|
||||||
static unregisterGlobalManager(manager: GlobalManager): void;
|
|
||||||
static getGlobalManager<T extends GlobalManager>(type: any): T;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
declare module es {
|
declare module es {
|
||||||
@@ -1421,7 +1428,6 @@ declare module es {
|
|||||||
}
|
}
|
||||||
class Input {
|
class Input {
|
||||||
private static _init;
|
private static _init;
|
||||||
private static _stage;
|
|
||||||
private static _previousTouchState;
|
private static _previousTouchState;
|
||||||
private static _gameTouchs;
|
private static _gameTouchs;
|
||||||
private static _resolutionOffset;
|
private static _resolutionOffset;
|
||||||
@@ -1434,7 +1440,7 @@ declare module es {
|
|||||||
static readonly totalTouchCount: number;
|
static readonly totalTouchCount: number;
|
||||||
static readonly gameTouchs: TouchState[];
|
static readonly gameTouchs: TouchState[];
|
||||||
static readonly touchPositionDelta: Vector2;
|
static readonly touchPositionDelta: Vector2;
|
||||||
static initialize(stage: egret.Stage): void;
|
static initialize(): void;
|
||||||
private static initTouchCache;
|
private static initTouchCache;
|
||||||
private static touchBegin;
|
private static touchBegin;
|
||||||
private static touchMove;
|
private static touchMove;
|
||||||
|
|||||||
+216
-170
@@ -955,8 +955,8 @@ var es;
|
|||||||
Debug.render = function () {
|
Debug.render = function () {
|
||||||
if (this._debugDrawItems.length > 0) {
|
if (this._debugDrawItems.length > 0) {
|
||||||
var debugShape = new egret.Shape();
|
var debugShape = new egret.Shape();
|
||||||
if (es.SceneManager.scene) {
|
if (es.Core.scene) {
|
||||||
es.SceneManager.scene.addChild(debugShape);
|
es.Core.scene.addChild(debugShape);
|
||||||
}
|
}
|
||||||
for (var i = this._debugDrawItems.length - 1; i >= 0; i--) {
|
for (var i = this._debugDrawItems.length - 1; i >= 0; i--) {
|
||||||
var item = this._debugDrawItems[i];
|
var item = this._debugDrawItems[i];
|
||||||
@@ -1097,10 +1097,167 @@ var es;
|
|||||||
es.Component = Component;
|
es.Component = Component;
|
||||||
})(es || (es = {}));
|
})(es || (es = {}));
|
||||||
var es;
|
var es;
|
||||||
|
(function (es) {
|
||||||
|
var Core = (function (_super) {
|
||||||
|
__extends(Core, _super);
|
||||||
|
function Core() {
|
||||||
|
var _this = _super.call(this) || this;
|
||||||
|
_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);
|
||||||
|
return _this;
|
||||||
|
}
|
||||||
|
Object.defineProperty(Core, "Instance", {
|
||||||
|
get: function () {
|
||||||
|
return this._instance;
|
||||||
|
},
|
||||||
|
enumerable: true,
|
||||||
|
configurable: true
|
||||||
|
});
|
||||||
|
Object.defineProperty(Core, "scene", {
|
||||||
|
get: function () {
|
||||||
|
return this._instance._scene;
|
||||||
|
},
|
||||||
|
set: function (value) {
|
||||||
|
if (!value) {
|
||||||
|
console.error("场景不能为空");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this._instance._scene == null) {
|
||||||
|
this._instance._scene = value;
|
||||||
|
this._instance._scene.begin();
|
||||||
|
Core.Instance.onSceneChanged();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this._instance._nextScene = value;
|
||||||
|
}
|
||||||
|
this.registerActiveSceneChanged(this._instance._scene, this._instance._nextScene);
|
||||||
|
},
|
||||||
|
enumerable: true,
|
||||||
|
configurable: true
|
||||||
|
});
|
||||||
|
Core.prototype.onOrientationChanged = function () {
|
||||||
|
Core.emitter.emit(es.CoreEvents.OrientationChanged);
|
||||||
|
};
|
||||||
|
Core.prototype.onGraphicsDeviceReset = function () {
|
||||||
|
Core.emitter.emit(es.CoreEvents.GraphicsDeviceReset);
|
||||||
|
};
|
||||||
|
Core.prototype.initialize = function () {
|
||||||
|
};
|
||||||
|
Core.prototype.update = function () {
|
||||||
|
this.startDebugUpdate();
|
||||||
|
es.Time.update(egret.getTimer());
|
||||||
|
if (this._scene) {
|
||||||
|
for (var i = this._globalManagers.length - 1; i >= 0; i--) {
|
||||||
|
if (this._globalManagers[i].enabled)
|
||||||
|
this._globalManagers[i].update();
|
||||||
|
}
|
||||||
|
if (!this._sceneTransition ||
|
||||||
|
(this._sceneTransition && (!this._sceneTransition.loadsNewScene || this._sceneTransition.isNewSceneLoaded))) {
|
||||||
|
this._scene.update();
|
||||||
|
}
|
||||||
|
if (this._nextScene) {
|
||||||
|
this._scene.end();
|
||||||
|
this._scene = this._nextScene;
|
||||||
|
this._nextScene = null;
|
||||||
|
this.onSceneChanged();
|
||||||
|
this._scene.begin();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.endDebugUpdate();
|
||||||
|
};
|
||||||
|
Core.prototype.draw = function () {
|
||||||
|
return __awaiter(this, void 0, void 0, function () {
|
||||||
|
return __generator(this, function (_a) {
|
||||||
|
switch (_a.label) {
|
||||||
|
case 0:
|
||||||
|
if (!this._sceneTransition) return [3, 4];
|
||||||
|
this._sceneTransition.preRender();
|
||||||
|
if (!(this._scene && !this._sceneTransition.hasPreviousSceneRender)) return [3, 2];
|
||||||
|
this._scene.render();
|
||||||
|
this._scene.postRender();
|
||||||
|
return [4, this._sceneTransition.onBeginTransition()];
|
||||||
|
case 1:
|
||||||
|
_a.sent();
|
||||||
|
return [3, 3];
|
||||||
|
case 2:
|
||||||
|
if (this._sceneTransition) {
|
||||||
|
if (this._scene && this._sceneTransition.isNewSceneLoaded) {
|
||||||
|
this._scene.render();
|
||||||
|
this._scene.postRender();
|
||||||
|
}
|
||||||
|
this._sceneTransition.render();
|
||||||
|
}
|
||||||
|
_a.label = 3;
|
||||||
|
case 3: return [3, 5];
|
||||||
|
case 4:
|
||||||
|
if (this._scene) {
|
||||||
|
this._scene.render();
|
||||||
|
es.Debug.render();
|
||||||
|
this._scene.postRender();
|
||||||
|
}
|
||||||
|
_a.label = 5;
|
||||||
|
case 5: return [2];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
Core.prototype.startDebugUpdate = function () {
|
||||||
|
es.TimeRuler.Instance.startFrame();
|
||||||
|
es.TimeRuler.Instance.beginMark("update", 0x00FF00);
|
||||||
|
};
|
||||||
|
Core.prototype.endDebugUpdate = function () {
|
||||||
|
es.TimeRuler.Instance.endMark("update");
|
||||||
|
};
|
||||||
|
Core.prototype.onSceneChanged = function () {
|
||||||
|
Core.emitter.emit(es.CoreEvents.SceneChanged);
|
||||||
|
es.Time.sceneChanged();
|
||||||
|
};
|
||||||
|
Core.startSceneTransition = function (sceneTransition) {
|
||||||
|
if (this._instance._sceneTransition) {
|
||||||
|
console.warn("在前一个场景完成之前,不能开始一个新的场景转换。");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
Core.unregisterGlobalManager = function (manager) {
|
||||||
|
this._instance._globalManagers.remove(manager);
|
||||||
|
manager.enabled = false;
|
||||||
|
};
|
||||||
|
Core.getGlobalManager = function (type) {
|
||||||
|
for (var i = 0; i < this._instance._globalManagers.length; i++) {
|
||||||
|
if (this._instance._globalManagers[i] instanceof type)
|
||||||
|
return this._instance._globalManagers[i];
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
return Core;
|
||||||
|
}(egret.DisplayObjectContainer));
|
||||||
|
es.Core = Core;
|
||||||
|
})(es || (es = {}));
|
||||||
|
var es;
|
||||||
(function (es) {
|
(function (es) {
|
||||||
var CoreEvents;
|
var CoreEvents;
|
||||||
(function (CoreEvents) {
|
(function (CoreEvents) {
|
||||||
CoreEvents[CoreEvents["SceneChanged"] = 0] = "SceneChanged";
|
CoreEvents[CoreEvents["GraphicsDeviceReset"] = 0] = "GraphicsDeviceReset";
|
||||||
|
CoreEvents[CoreEvents["SceneChanged"] = 1] = "SceneChanged";
|
||||||
|
CoreEvents[CoreEvents["OrientationChanged"] = 2] = "OrientationChanged";
|
||||||
})(CoreEvents = es.CoreEvents || (es.CoreEvents = {}));
|
})(CoreEvents = es.CoreEvents || (es.CoreEvents = {}));
|
||||||
})(es || (es = {}));
|
})(es || (es = {}));
|
||||||
var es;
|
var es;
|
||||||
@@ -1347,8 +1504,6 @@ var es;
|
|||||||
_this.renderableComponents = new es.RenderableComponentList();
|
_this.renderableComponents = new es.RenderableComponentList();
|
||||||
_this.content = new es.ContentManager();
|
_this.content = new es.ContentManager();
|
||||||
_this.entityProcessors = new es.EntityProcessorList();
|
_this.entityProcessors = new es.EntityProcessorList();
|
||||||
_this.width = es.SceneManager.stage.stageWidth;
|
|
||||||
_this.height = es.SceneManager.stage.stageHeight;
|
|
||||||
_this.initialize();
|
_this.initialize();
|
||||||
return _this;
|
return _this;
|
||||||
}
|
}
|
||||||
@@ -1369,12 +1524,6 @@ var es;
|
|||||||
Scene.prototype.begin = function () {
|
Scene.prototype.begin = function () {
|
||||||
return __awaiter(this, void 0, void 0, function () {
|
return __awaiter(this, void 0, void 0, function () {
|
||||||
return __generator(this, function (_a) {
|
return __generator(this, function (_a) {
|
||||||
if (es.SceneManager.sceneTransition) {
|
|
||||||
es.SceneManager.stage.addChildAt(this, es.SceneManager.stage.numChildren - 1);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
es.SceneManager.stage.addChild(this);
|
|
||||||
}
|
|
||||||
if (this._renderers.length == 0) {
|
if (this._renderers.length == 0) {
|
||||||
this.addRenderer(new es.DefaultRenderer());
|
this.addRenderer(new es.DefaultRenderer());
|
||||||
console.warn("场景开始时没有渲染器 自动添加DefaultRenderer以保证能够正常渲染");
|
console.warn("场景开始时没有渲染器 自动添加DefaultRenderer以保证能够正常渲染");
|
||||||
@@ -1528,120 +1677,6 @@ var es;
|
|||||||
}(egret.DisplayObjectContainer));
|
}(egret.DisplayObjectContainer));
|
||||||
es.Scene = Scene;
|
es.Scene = Scene;
|
||||||
})(es || (es = {}));
|
})(es || (es = {}));
|
||||||
var es;
|
|
||||||
(function (es) {
|
|
||||||
var SceneManager = (function () {
|
|
||||||
function SceneManager(stage) {
|
|
||||||
stage.addEventListener(egret.Event.ENTER_FRAME, SceneManager.update, this);
|
|
||||||
SceneManager._instnace = this;
|
|
||||||
SceneManager.emitter = new es.Emitter();
|
|
||||||
SceneManager.content = new es.ContentManager();
|
|
||||||
SceneManager.stage = stage;
|
|
||||||
SceneManager.initialize(stage);
|
|
||||||
SceneManager.timerRuler = new es.TimeRuler();
|
|
||||||
}
|
|
||||||
Object.defineProperty(SceneManager, "Instance", {
|
|
||||||
get: function () {
|
|
||||||
return this._instnace;
|
|
||||||
},
|
|
||||||
enumerable: true,
|
|
||||||
configurable: true
|
|
||||||
});
|
|
||||||
Object.defineProperty(SceneManager, "scene", {
|
|
||||||
get: function () {
|
|
||||||
return this._scene;
|
|
||||||
},
|
|
||||||
set: function (value) {
|
|
||||||
if (!value)
|
|
||||||
throw new Error("场景不能为空");
|
|
||||||
if (this._scene == null) {
|
|
||||||
this._scene = value;
|
|
||||||
this._scene.begin();
|
|
||||||
SceneManager.Instance.onSceneChanged();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
this._nextScene = value;
|
|
||||||
}
|
|
||||||
this.registerActiveSceneChanged(this._scene, this._nextScene);
|
|
||||||
},
|
|
||||||
enumerable: true,
|
|
||||||
configurable: true
|
|
||||||
});
|
|
||||||
SceneManager.initialize = function (stage) {
|
|
||||||
es.Input.initialize(stage);
|
|
||||||
};
|
|
||||||
SceneManager.update = function () {
|
|
||||||
SceneManager.startDebugUpdate();
|
|
||||||
es.Time.update(egret.getTimer());
|
|
||||||
if (SceneManager._scene) {
|
|
||||||
for (var i = es.GlobalManager.globalManagers.length - 1; i >= 0; i--) {
|
|
||||||
if (es.GlobalManager.globalManagers[i].enabled)
|
|
||||||
es.GlobalManager.globalManagers[i].update();
|
|
||||||
}
|
|
||||||
if (!SceneManager.sceneTransition ||
|
|
||||||
(SceneManager.sceneTransition && (!SceneManager.sceneTransition.loadsNewScene || SceneManager.sceneTransition.isNewSceneLoaded))) {
|
|
||||||
SceneManager._scene.update();
|
|
||||||
}
|
|
||||||
if (SceneManager._nextScene) {
|
|
||||||
SceneManager._scene.end();
|
|
||||||
SceneManager._scene = SceneManager._nextScene;
|
|
||||||
SceneManager._nextScene = null;
|
|
||||||
SceneManager._instnace.onSceneChanged();
|
|
||||||
SceneManager._scene.begin();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
SceneManager.endDebugUpdate();
|
|
||||||
SceneManager.render();
|
|
||||||
};
|
|
||||||
SceneManager.render = function () {
|
|
||||||
if (this.sceneTransition) {
|
|
||||||
this.sceneTransition.preRender();
|
|
||||||
if (this._scene && !this.sceneTransition.hasPreviousSceneRender) {
|
|
||||||
this._scene.render();
|
|
||||||
this._scene.postRender();
|
|
||||||
this.sceneTransition.onBeginTransition();
|
|
||||||
}
|
|
||||||
else if (this.sceneTransition) {
|
|
||||||
if (this._scene && this.sceneTransition.isNewSceneLoaded) {
|
|
||||||
this._scene.render();
|
|
||||||
this._scene.postRender();
|
|
||||||
}
|
|
||||||
this.sceneTransition.render();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (this._scene) {
|
|
||||||
this._scene.render();
|
|
||||||
es.Debug.render();
|
|
||||||
this._scene.postRender();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
SceneManager.startSceneTransition = function (sceneTransition) {
|
|
||||||
if (this.sceneTransition) {
|
|
||||||
console.warn("在前一个场景完成之前,不能开始一个新的场景转换。");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.sceneTransition = sceneTransition;
|
|
||||||
return sceneTransition;
|
|
||||||
};
|
|
||||||
SceneManager.registerActiveSceneChanged = function (current, next) {
|
|
||||||
if (this.activeSceneChanged)
|
|
||||||
this.activeSceneChanged(current, next);
|
|
||||||
};
|
|
||||||
SceneManager.prototype.onSceneChanged = function () {
|
|
||||||
SceneManager.emitter.emit(es.CoreEvents.SceneChanged);
|
|
||||||
es.Time.sceneChanged();
|
|
||||||
};
|
|
||||||
SceneManager.startDebugUpdate = function () {
|
|
||||||
es.TimeRuler.Instance.startFrame();
|
|
||||||
es.TimeRuler.Instance.beginMark("update", 0x00FF00);
|
|
||||||
};
|
|
||||||
SceneManager.endDebugUpdate = function () {
|
|
||||||
es.TimeRuler.Instance.endMark("update");
|
|
||||||
};
|
|
||||||
return SceneManager;
|
|
||||||
}());
|
|
||||||
es.SceneManager = SceneManager;
|
|
||||||
})(es || (es = {}));
|
|
||||||
var transform;
|
var transform;
|
||||||
(function (transform) {
|
(function (transform) {
|
||||||
var Component;
|
var Component;
|
||||||
@@ -1851,10 +1886,10 @@ var es;
|
|||||||
this.updateMatrixes();
|
this.updateMatrixes();
|
||||||
if (this._areBoundsDirty) {
|
if (this._areBoundsDirty) {
|
||||||
var topLeft = this.screenToWorldPoint(new es.Vector2(this._inset.left, this._inset.top));
|
var topLeft = this.screenToWorldPoint(new es.Vector2(this._inset.left, this._inset.top));
|
||||||
var bottomRight = this.screenToWorldPoint(new es.Vector2(es.SceneManager.stage.stageWidth - this._inset.right, es.SceneManager.stage.stageHeight - this._inset.bottom));
|
var bottomRight = this.screenToWorldPoint(new es.Vector2(es.Core.graphicsDevice.viewport.width - this._inset.right, es.Core.graphicsDevice.viewport.height - this._inset.bottom));
|
||||||
if (this.entity.transform.rotation != 0) {
|
if (this.entity.transform.rotation != 0) {
|
||||||
var topRight = this.screenToWorldPoint(new es.Vector2(es.SceneManager.stage.stageWidth - this._inset.right, this._inset.top));
|
var topRight = this.screenToWorldPoint(new es.Vector2(es.Core.graphicsDevice.viewport.width - this._inset.right, this._inset.top));
|
||||||
var bottomLeft = this.screenToWorldPoint(new es.Vector2(this._inset.left, es.SceneManager.stage.stageHeight - this._inset.bottom));
|
var bottomLeft = this.screenToWorldPoint(new es.Vector2(this._inset.left, es.Core.graphicsDevice.viewport.height - this._inset.bottom));
|
||||||
var minX = Math.min(topLeft.x, bottomRight.x, topRight.x, bottomLeft.x);
|
var minX = Math.min(topLeft.x, bottomRight.x, topRight.x, bottomLeft.x);
|
||||||
var maxX = Math.max(topLeft.x, bottomRight.x, topRight.x, bottomLeft.x);
|
var maxX = Math.max(topLeft.x, bottomRight.x, topRight.x, bottomLeft.x);
|
||||||
var minY = Math.min(topLeft.y, bottomRight.y, topRight.y, bottomLeft.y);
|
var minY = Math.min(topLeft.y, bottomRight.y, topRight.y, bottomLeft.y);
|
||||||
@@ -2008,8 +2043,8 @@ var es;
|
|||||||
};
|
};
|
||||||
Camera.prototype.update = function () {
|
Camera.prototype.update = function () {
|
||||||
var halfScreen = es.Vector2.multiply(new es.Vector2(this.bounds.width, this.bounds.height), new es.Vector2(0.5));
|
var halfScreen = es.Vector2.multiply(new es.Vector2(this.bounds.width, this.bounds.height), new es.Vector2(0.5));
|
||||||
this._worldSpaceDeadZone.x = this.position.x - halfScreen.x * es.SceneManager.scene.scaleX + this.deadzone.x + this.focusOffset.x;
|
this._worldSpaceDeadZone.x = this.position.x - halfScreen.x * es.Core.scene.scaleX + this.deadzone.x + this.focusOffset.x;
|
||||||
this._worldSpaceDeadZone.y = this.position.y - halfScreen.y * es.SceneManager.scene.scaleY + this.deadzone.y + this.focusOffset.y;
|
this._worldSpaceDeadZone.y = this.position.y - halfScreen.y * es.Core.scene.scaleY + this.deadzone.y + this.focusOffset.y;
|
||||||
this._worldSpaceDeadZone.width = this.deadzone.width;
|
this._worldSpaceDeadZone.width = this.deadzone.width;
|
||||||
this._worldSpaceDeadZone.height = this.deadzone.height;
|
this._worldSpaceDeadZone.height = this.deadzone.height;
|
||||||
if (this._targetEntity)
|
if (this._targetEntity)
|
||||||
@@ -4021,7 +4056,7 @@ var es;
|
|||||||
var offsetY = Math.round(bitmapData.$offsetY);
|
var offsetY = Math.round(bitmapData.$offsetY);
|
||||||
var bitmapWidth = bitmapData.$bitmapWidth;
|
var bitmapWidth = bitmapData.$bitmapWidth;
|
||||||
var bitmapHeight = bitmapData.$bitmapHeight;
|
var bitmapHeight = bitmapData.$bitmapHeight;
|
||||||
var $TextureScaleFactor = es.SceneManager.stage.textureScaleFactor;
|
var $TextureScaleFactor = es.Core._instance.stage.textureScaleFactor;
|
||||||
this.sharedContext.drawImage(bitmapData.$bitmapData.source, bitmapData.$bitmapX + rect.x / $TextureScaleFactor, bitmapData.$bitmapY + rect.y / $TextureScaleFactor, bitmapWidth * rect.width / w, bitmapHeight * rect.height / h, offsetX, offsetY, rect.width, rect.height);
|
this.sharedContext.drawImage(bitmapData.$bitmapData.source, bitmapData.$bitmapX + rect.x / $TextureScaleFactor, bitmapData.$bitmapY + rect.y / $TextureScaleFactor, bitmapWidth * rect.width / w, bitmapHeight * rect.height / h, offsetX, offsetY, rect.width, rect.height);
|
||||||
return surface;
|
return surface;
|
||||||
}
|
}
|
||||||
@@ -4300,9 +4335,20 @@ var es;
|
|||||||
(function (es) {
|
(function (es) {
|
||||||
var GraphicsDevice = (function () {
|
var GraphicsDevice = (function () {
|
||||||
function GraphicsDevice() {
|
function GraphicsDevice() {
|
||||||
|
this.setup();
|
||||||
this.graphicsCapabilities = new es.GraphicsCapabilities();
|
this.graphicsCapabilities = new es.GraphicsCapabilities();
|
||||||
this.graphicsCapabilities.initialize(this);
|
this.graphicsCapabilities.initialize(this);
|
||||||
}
|
}
|
||||||
|
Object.defineProperty(GraphicsDevice.prototype, "viewport", {
|
||||||
|
get: function () {
|
||||||
|
return this._viewport;
|
||||||
|
},
|
||||||
|
enumerable: true,
|
||||||
|
configurable: true
|
||||||
|
});
|
||||||
|
GraphicsDevice.prototype.setup = function () {
|
||||||
|
this._viewport = new es.Viewport(0, 0, es.Core._instance.stage.stageWidth, es.Core._instance.stage.stageHeight);
|
||||||
|
};
|
||||||
return GraphicsDevice;
|
return GraphicsDevice;
|
||||||
}());
|
}());
|
||||||
es.GraphicsDevice = GraphicsDevice;
|
es.GraphicsDevice = GraphicsDevice;
|
||||||
@@ -4318,6 +4364,26 @@ var es;
|
|||||||
this._minDepth = 0;
|
this._minDepth = 0;
|
||||||
this._maxDepth = 1;
|
this._maxDepth = 1;
|
||||||
}
|
}
|
||||||
|
Object.defineProperty(Viewport.prototype, "height", {
|
||||||
|
get: function () {
|
||||||
|
return this._height;
|
||||||
|
},
|
||||||
|
set: function (value) {
|
||||||
|
this._height = value;
|
||||||
|
},
|
||||||
|
enumerable: true,
|
||||||
|
configurable: true
|
||||||
|
});
|
||||||
|
Object.defineProperty(Viewport.prototype, "width", {
|
||||||
|
get: function () {
|
||||||
|
return this._width;
|
||||||
|
},
|
||||||
|
set: function (value) {
|
||||||
|
this._width = value;
|
||||||
|
},
|
||||||
|
enumerable: true,
|
||||||
|
configurable: true
|
||||||
|
});
|
||||||
Object.defineProperty(Viewport.prototype, "aspectRatio", {
|
Object.defineProperty(Viewport.prototype, "aspectRatio", {
|
||||||
get: function () {
|
get: function () {
|
||||||
if ((this._height != 0) && (this._width != 0))
|
if ((this._height != 0) && (this._width != 0))
|
||||||
@@ -4350,8 +4416,8 @@ var es;
|
|||||||
__extends(GaussianBlurEffect, _super);
|
__extends(GaussianBlurEffect, _super);
|
||||||
function GaussianBlurEffect() {
|
function GaussianBlurEffect() {
|
||||||
return _super.call(this, es.PostProcessor.default_vert, GaussianBlurEffect.blur_frag, {
|
return _super.call(this, es.PostProcessor.default_vert, GaussianBlurEffect.blur_frag, {
|
||||||
screenWidth: es.SceneManager.stage.stageWidth,
|
screenWidth: es.Core.graphicsDevice.viewport.width,
|
||||||
screenHeight: es.SceneManager.stage.stageHeight
|
screenHeight: es.Core.graphicsDevice.viewport.height
|
||||||
}) || this;
|
}) || this;
|
||||||
}
|
}
|
||||||
GaussianBlurEffect.blur_frag = "precision mediump float;\n" +
|
GaussianBlurEffect.blur_frag = "precision mediump float;\n" +
|
||||||
@@ -4435,7 +4501,7 @@ var es;
|
|||||||
this.scene = scene;
|
this.scene = scene;
|
||||||
this.shape = new egret.Shape();
|
this.shape = new egret.Shape();
|
||||||
this.shape.graphics.beginFill(0xFFFFFF, 1);
|
this.shape.graphics.beginFill(0xFFFFFF, 1);
|
||||||
this.shape.graphics.drawRect(0, 0, es.SceneManager.stage.stageWidth, es.SceneManager.stage.stageHeight);
|
this.shape.graphics.drawRect(0, 0, es.Core.graphicsDevice.viewport.width, es.Core.graphicsDevice.viewport.height);
|
||||||
this.shape.graphics.endFill();
|
this.shape.graphics.endFill();
|
||||||
scene.addChild(this.shape);
|
scene.addChild(this.shape);
|
||||||
};
|
};
|
||||||
@@ -4614,7 +4680,7 @@ var es;
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
SceneTransition.prototype.transitionComplete = function () {
|
SceneTransition.prototype.transitionComplete = function () {
|
||||||
es.SceneManager.sceneTransition = null;
|
es.Core._instance._sceneTransition = null;
|
||||||
if (this.onTransitionCompleted) {
|
if (this.onTransitionCompleted) {
|
||||||
this.onTransitionCompleted();
|
this.onTransitionCompleted();
|
||||||
}
|
}
|
||||||
@@ -4630,7 +4696,7 @@ var es;
|
|||||||
if (!this.loadsNewScene) {
|
if (!this.loadsNewScene) {
|
||||||
this.isNewSceneLoaded = true;
|
this.isNewSceneLoaded = true;
|
||||||
}
|
}
|
||||||
_a = es.SceneManager;
|
_a = es.Core;
|
||||||
return [4, this.sceneLoadAction()];
|
return [4, this.sceneLoadAction()];
|
||||||
case 1:
|
case 1:
|
||||||
_a.scene = _b.sent();
|
_a.scene = _b.sent();
|
||||||
@@ -4673,9 +4739,8 @@ var es;
|
|||||||
var _this = this;
|
var _this = this;
|
||||||
return __generator(this, function (_a) {
|
return __generator(this, function (_a) {
|
||||||
this._mask.graphics.beginFill(this.fadeToColor, 1);
|
this._mask.graphics.beginFill(this.fadeToColor, 1);
|
||||||
this._mask.graphics.drawRect(0, 0, es.SceneManager.stage.stageWidth, es.SceneManager.stage.stageHeight);
|
this._mask.graphics.drawRect(0, 0, es.Core.graphicsDevice.viewport.width, es.Core.graphicsDevice.viewport.height);
|
||||||
this._mask.graphics.endFill();
|
this._mask.graphics.endFill();
|
||||||
es.SceneManager.stage.addChild(this._mask);
|
|
||||||
egret.Tween.get(this).to({ _alpha: 1 }, this.fadeOutDuration * 1000, this.fadeEaseType)
|
egret.Tween.get(this).to({ _alpha: 1 }, this.fadeOutDuration * 1000, this.fadeEaseType)
|
||||||
.call(function () { return __awaiter(_this, void 0, void 0, function () {
|
.call(function () { return __awaiter(_this, void 0, void 0, function () {
|
||||||
return __generator(this, function (_a) {
|
return __generator(this, function (_a) {
|
||||||
@@ -4689,7 +4754,6 @@ var es;
|
|||||||
}); }).wait(this.delayBeforeFadeInDuration).call(function () {
|
}); }).wait(this.delayBeforeFadeInDuration).call(function () {
|
||||||
egret.Tween.get(_this).to({ _alpha: 0 }, _this.fadeOutDuration * 1000, _this.fadeEaseType).call(function () {
|
egret.Tween.get(_this).to({ _alpha: 0 }, _this.fadeOutDuration * 1000, _this.fadeEaseType).call(function () {
|
||||||
_this.transitionComplete();
|
_this.transitionComplete();
|
||||||
es.SceneManager.stage.removeChild(_this._mask);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return [2];
|
return [2];
|
||||||
@@ -4699,7 +4763,7 @@ var es;
|
|||||||
FadeTransition.prototype.render = function () {
|
FadeTransition.prototype.render = function () {
|
||||||
this._mask.graphics.clear();
|
this._mask.graphics.clear();
|
||||||
this._mask.graphics.beginFill(this.fadeToColor, this._alpha);
|
this._mask.graphics.beginFill(this.fadeToColor, this._alpha);
|
||||||
this._mask.graphics.drawRect(0, 0, es.SceneManager.stage.stageWidth, es.SceneManager.stage.stageHeight);
|
this._mask.graphics.drawRect(0, 0, es.Core.graphicsDevice.viewport.width, es.Core.graphicsDevice.viewport.height);
|
||||||
this._mask.graphics.endFill();
|
this._mask.graphics.endFill();
|
||||||
};
|
};
|
||||||
return FadeTransition;
|
return FadeTransition;
|
||||||
@@ -4744,10 +4808,9 @@ var es;
|
|||||||
});
|
});
|
||||||
_this._mask = new egret.Shape();
|
_this._mask = new egret.Shape();
|
||||||
_this._mask.graphics.beginFill(0xFFFFFF, 1);
|
_this._mask.graphics.beginFill(0xFFFFFF, 1);
|
||||||
_this._mask.graphics.drawRect(0, 0, es.SceneManager.stage.stageWidth, es.SceneManager.stage.stageHeight);
|
_this._mask.graphics.drawRect(0, 0, es.Core.graphicsDevice.viewport.width, es.Core.graphicsDevice.viewport.height);
|
||||||
_this._mask.graphics.endFill();
|
_this._mask.graphics.endFill();
|
||||||
_this._mask.filters = [_this._windEffect];
|
_this._mask.filters = [_this._windEffect];
|
||||||
es.SceneManager.stage.addChild(_this._mask);
|
|
||||||
return _this;
|
return _this;
|
||||||
}
|
}
|
||||||
Object.defineProperty(WindTransition.prototype, "windSegments", {
|
Object.defineProperty(WindTransition.prototype, "windSegments", {
|
||||||
@@ -4774,7 +4837,6 @@ var es;
|
|||||||
case 1:
|
case 1:
|
||||||
_a.sent();
|
_a.sent();
|
||||||
this.transitionComplete();
|
this.transitionComplete();
|
||||||
es.SceneManager.stage.removeChild(this._mask);
|
|
||||||
return [2];
|
return [2];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -6625,22 +6687,6 @@ var es;
|
|||||||
GlobalManager.prototype.onEnabled = function () { };
|
GlobalManager.prototype.onEnabled = function () { };
|
||||||
GlobalManager.prototype.onDisabled = function () { };
|
GlobalManager.prototype.onDisabled = function () { };
|
||||||
GlobalManager.prototype.update = function () { };
|
GlobalManager.prototype.update = function () { };
|
||||||
GlobalManager.registerGlobalManager = function (manager) {
|
|
||||||
this.globalManagers.push(manager);
|
|
||||||
manager.enabled = true;
|
|
||||||
};
|
|
||||||
GlobalManager.unregisterGlobalManager = function (manager) {
|
|
||||||
this.globalManagers.remove(manager);
|
|
||||||
manager.enabled = false;
|
|
||||||
};
|
|
||||||
GlobalManager.getGlobalManager = function (type) {
|
|
||||||
for (var i = 0; i < this.globalManagers.length; i++) {
|
|
||||||
if (this.globalManagers[i] instanceof type)
|
|
||||||
return this.globalManagers[i];
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
GlobalManager.globalManagers = [];
|
|
||||||
return GlobalManager;
|
return GlobalManager;
|
||||||
}());
|
}());
|
||||||
es.GlobalManager = GlobalManager;
|
es.GlobalManager = GlobalManager;
|
||||||
@@ -6684,10 +6730,10 @@ var es;
|
|||||||
});
|
});
|
||||||
Object.defineProperty(Input, "maxSupportedTouch", {
|
Object.defineProperty(Input, "maxSupportedTouch", {
|
||||||
get: function () {
|
get: function () {
|
||||||
return this._stage.maxTouches;
|
return es.Core._instance.stage.maxTouches;
|
||||||
},
|
},
|
||||||
set: function (value) {
|
set: function (value) {
|
||||||
this._stage.maxTouches = value;
|
es.Core._instance.stage.maxTouches = value;
|
||||||
this.initTouchCache();
|
this.initTouchCache();
|
||||||
},
|
},
|
||||||
enumerable: true,
|
enumerable: true,
|
||||||
@@ -6725,16 +6771,15 @@ var es;
|
|||||||
enumerable: true,
|
enumerable: true,
|
||||||
configurable: true
|
configurable: true
|
||||||
});
|
});
|
||||||
Input.initialize = function (stage) {
|
Input.initialize = function () {
|
||||||
if (this._init)
|
if (this._init)
|
||||||
return;
|
return;
|
||||||
this._init = true;
|
this._init = true;
|
||||||
this._stage = stage;
|
es.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.touchBegin, this);
|
||||||
this._stage.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.touchBegin, this);
|
es.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_MOVE, this.touchMove, this);
|
||||||
this._stage.addEventListener(egret.TouchEvent.TOUCH_MOVE, this.touchMove, this);
|
es.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_END, this.touchEnd, this);
|
||||||
this._stage.addEventListener(egret.TouchEvent.TOUCH_END, this.touchEnd, this);
|
es.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_CANCEL, this.touchEnd, this);
|
||||||
this._stage.addEventListener(egret.TouchEvent.TOUCH_CANCEL, this.touchEnd, this);
|
es.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_RELEASE_OUTSIDE, this.touchEnd, this);
|
||||||
this._stage.addEventListener(egret.TouchEvent.TOUCH_RELEASE_OUTSIDE, this.touchEnd, this);
|
|
||||||
this.initTouchCache();
|
this.initTouchCache();
|
||||||
};
|
};
|
||||||
Input.initTouchCache = function () {
|
Input.initTouchCache = function () {
|
||||||
@@ -7324,7 +7369,7 @@ var es;
|
|||||||
(function (es) {
|
(function (es) {
|
||||||
var Layout = (function () {
|
var Layout = (function () {
|
||||||
function Layout() {
|
function Layout() {
|
||||||
this.clientArea = new es.Rectangle(0, 0, es.SceneManager.stage.stageWidth, es.SceneManager.stage.stageHeight);
|
this.clientArea = new es.Rectangle(0, 0, es.Core.graphicsDevice.viewport.width, es.Core.graphicsDevice.viewport.height);
|
||||||
this.safeArea = this.clientArea;
|
this.safeArea = this.clientArea;
|
||||||
}
|
}
|
||||||
Layout.prototype.place = function (size, horizontalMargin, verticalMargine, alignment) {
|
Layout.prototype.place = function (size, horizontalMargin, verticalMargine, alignment) {
|
||||||
@@ -7530,7 +7575,8 @@ var es;
|
|||||||
for (var i = 0; i < this._logs.length; ++i)
|
for (var i = 0; i < this._logs.length; ++i)
|
||||||
this._logs[i] = new FrameLog();
|
this._logs[i] = new FrameLog();
|
||||||
this.sampleFrames = this.targetSampleFrames = 1;
|
this.sampleFrames = this.targetSampleFrames = 1;
|
||||||
this.width = es.SceneManager.stage.stageWidth * 0.8;
|
this.width = es.Core.graphicsDevice.viewport.width * 0.8;
|
||||||
|
es.Core.emitter.addObserver(es.CoreEvents.GraphicsDeviceReset, this.onGraphicsDeviceReset, this);
|
||||||
this.onGraphicsDeviceReset();
|
this.onGraphicsDeviceReset();
|
||||||
}
|
}
|
||||||
TimeRuler.prototype.onGraphicsDeviceReset = function () {
|
TimeRuler.prototype.onGraphicsDeviceReset = function () {
|
||||||
|
|||||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -9,8 +9,8 @@ module es {
|
|||||||
public static render(){
|
public static render(){
|
||||||
if (this._debugDrawItems.length > 0){
|
if (this._debugDrawItems.length > 0){
|
||||||
let debugShape = new egret.Shape();
|
let debugShape = new egret.Shape();
|
||||||
if (SceneManager.scene){
|
if (Core.scene){
|
||||||
SceneManager.scene.addChild(debugShape);
|
Core.scene.addChild(debugShape);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i = this._debugDrawItems.length - 1; i >= 0; i --){
|
for (let i = this._debugDrawItems.length - 1; i >= 0; i --){
|
||||||
|
|||||||
@@ -105,15 +105,15 @@ module es {
|
|||||||
if (this._areBoundsDirty){
|
if (this._areBoundsDirty){
|
||||||
// 旋转或非旋转的边界都需要左上角和右下角
|
// 旋转或非旋转的边界都需要左上角和右下角
|
||||||
let topLeft = this.screenToWorldPoint(new Vector2(this._inset.left, this._inset.top));
|
let topLeft = this.screenToWorldPoint(new Vector2(this._inset.left, this._inset.top));
|
||||||
let bottomRight = this.screenToWorldPoint(new Vector2(SceneManager.stage.stageWidth - this._inset.right,
|
let bottomRight = this.screenToWorldPoint(new Vector2(Core.graphicsDevice.viewport.width - this._inset.right,
|
||||||
SceneManager.stage.stageHeight - this._inset.bottom));
|
Core.graphicsDevice.viewport.height - this._inset.bottom));
|
||||||
|
|
||||||
if (this.entity.transform.rotation != 0){
|
if (this.entity.transform.rotation != 0){
|
||||||
// 特别注意旋转的边界。我们需要找到绝对的最小/最大值并从中创建边界
|
// 特别注意旋转的边界。我们需要找到绝对的最小/最大值并从中创建边界
|
||||||
let topRight = this.screenToWorldPoint(new Vector2(SceneManager.stage.stageWidth - this._inset.right,
|
let topRight = this.screenToWorldPoint(new Vector2(Core.graphicsDevice.viewport.width - this._inset.right,
|
||||||
this._inset.top));
|
this._inset.top));
|
||||||
let bottomLeft = this.screenToWorldPoint(new Vector2(this._inset.left,
|
let bottomLeft = this.screenToWorldPoint(new Vector2(this._inset.left,
|
||||||
SceneManager.stage.stageHeight - this._inset.bottom));
|
Core.graphicsDevice.viewport.height - this._inset.bottom));
|
||||||
|
|
||||||
let minX = Math.min(topLeft.x, bottomRight.x, topRight.x, bottomLeft.x);
|
let minX = Math.min(topLeft.x, bottomRight.x, topRight.x, bottomLeft.x);
|
||||||
let maxX = Math.max(topLeft.x, bottomRight.x, topRight.x, bottomLeft.x);
|
let maxX = Math.max(topLeft.x, bottomRight.x, topRight.x, bottomLeft.x);
|
||||||
@@ -386,8 +386,8 @@ module es {
|
|||||||
|
|
||||||
public update() {
|
public update() {
|
||||||
let halfScreen = Vector2.multiply(new Vector2(this.bounds.width, this.bounds.height), new Vector2(0.5));
|
let halfScreen = Vector2.multiply(new Vector2(this.bounds.width, this.bounds.height), new Vector2(0.5));
|
||||||
this._worldSpaceDeadZone.x = this.position.x - halfScreen.x * SceneManager.scene.scaleX + this.deadzone.x + this.focusOffset.x;
|
this._worldSpaceDeadZone.x = this.position.x - halfScreen.x * Core.scene.scaleX + this.deadzone.x + this.focusOffset.x;
|
||||||
this._worldSpaceDeadZone.y = this.position.y - halfScreen.y * SceneManager.scene.scaleY + this.deadzone.y + this.focusOffset.y;
|
this._worldSpaceDeadZone.y = this.position.y - halfScreen.y * Core.scene.scaleY + this.deadzone.y + this.focusOffset.y;
|
||||||
this._worldSpaceDeadZone.width = this.deadzone.width;
|
this._worldSpaceDeadZone.width = this.deadzone.width;
|
||||||
this._worldSpaceDeadZone.height = this.deadzone.height;
|
this._worldSpaceDeadZone.height = this.deadzone.height;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,228 @@
|
|||||||
|
module es {
|
||||||
|
/**
|
||||||
|
* 全局核心类
|
||||||
|
*/
|
||||||
|
export class Core extends egret.DisplayObjectContainer {
|
||||||
|
/**
|
||||||
|
* 订阅此事件以在活动场景发生更改时得到通知。
|
||||||
|
*/
|
||||||
|
public static activeSceneChanged: Function;
|
||||||
|
/**
|
||||||
|
* 核心发射器。只发出核心级别的事件
|
||||||
|
*/
|
||||||
|
public static emitter: Emitter<CoreEvents>;
|
||||||
|
/**
|
||||||
|
* 全局访问图形设备
|
||||||
|
*/
|
||||||
|
public static graphicsDevice: GraphicsDevice;
|
||||||
|
/**
|
||||||
|
* 全局内容管理器加载任何应该停留在场景之间的资产
|
||||||
|
*/
|
||||||
|
public static content: ContentManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 提供对单例/游戏实例的访问
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
public static get Instance(){
|
||||||
|
return this._instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 简化对内部类的全局内容实例的访问
|
||||||
|
*/
|
||||||
|
public static _instance: Core;
|
||||||
|
public _scene: Scene;
|
||||||
|
public _nextScene: Scene;
|
||||||
|
public _sceneTransition: SceneTransition;
|
||||||
|
/**
|
||||||
|
* 全局访问系统
|
||||||
|
*/
|
||||||
|
public _globalManagers: GlobalManager[] = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当前活动的场景。注意,如果设置了该设置,在更新结束之前场景实际上不会改变
|
||||||
|
*/
|
||||||
|
public static get scene() {
|
||||||
|
return this._instance._scene;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当前活动的场景。注意,如果设置了该设置,在更新结束之前场景实际上不会改变
|
||||||
|
* @param value
|
||||||
|
*/
|
||||||
|
public static set scene(value: Scene) {
|
||||||
|
if (!value){
|
||||||
|
console.error("场景不能为空");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this._instance._scene == null) {
|
||||||
|
this._instance._scene = value;
|
||||||
|
this._instance._scene.begin();
|
||||||
|
Core.Instance.onSceneChanged();
|
||||||
|
} else {
|
||||||
|
this._instance._nextScene = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.registerActiveSceneChanged(this._instance._scene, this._instance._nextScene);
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
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.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);
|
||||||
|
}
|
||||||
|
|
||||||
|
public onOrientationChanged(){
|
||||||
|
Core.emitter.emit(CoreEvents.OrientationChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当屏幕大小发生改变时调用
|
||||||
|
*/
|
||||||
|
protected onGraphicsDeviceReset(){
|
||||||
|
Core.emitter.emit(CoreEvents.GraphicsDeviceReset);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected initialize(){
|
||||||
|
}
|
||||||
|
|
||||||
|
protected update() {
|
||||||
|
this.startDebugUpdate();
|
||||||
|
|
||||||
|
// 更新我们所有的系统管理器
|
||||||
|
Time.update(egret.getTimer());
|
||||||
|
|
||||||
|
if (this._scene) {
|
||||||
|
for (let i = this._globalManagers.length - 1; i >= 0; i--) {
|
||||||
|
if (this._globalManagers[i].enabled)
|
||||||
|
this._globalManagers[i].update();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 仔细阅读:
|
||||||
|
// 当场景转换发生时,我们不会更新场景
|
||||||
|
// -除非是不改变场景的场景转换(没有理由不更新)
|
||||||
|
// -或者它是一个已经切换到新场景的场景转换(新场景需要做它自己的事情)
|
||||||
|
if (!this._sceneTransition ||
|
||||||
|
(this._sceneTransition && (!this._sceneTransition.loadsNewScene || this._sceneTransition.isNewSceneLoaded))) {
|
||||||
|
this._scene.update();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this._nextScene) {
|
||||||
|
this._scene.end();
|
||||||
|
|
||||||
|
this._scene = this._nextScene;
|
||||||
|
this._nextScene = null;
|
||||||
|
this.onSceneChanged();
|
||||||
|
|
||||||
|
this._scene.begin();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.endDebugUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async draw() {
|
||||||
|
if (this._sceneTransition){
|
||||||
|
this._sceneTransition.preRender();
|
||||||
|
|
||||||
|
// 如果我们有场景转换的特殊处理。我们要么渲染场景过渡,要么渲染场景
|
||||||
|
if (this._scene && !this._sceneTransition.hasPreviousSceneRender){
|
||||||
|
this._scene.render();
|
||||||
|
this._scene.postRender();
|
||||||
|
await this._sceneTransition.onBeginTransition();
|
||||||
|
} else if (this._sceneTransition) {
|
||||||
|
if (this._scene && this._sceneTransition.isNewSceneLoaded) {
|
||||||
|
this._scene.render();
|
||||||
|
this._scene.postRender();
|
||||||
|
}
|
||||||
|
|
||||||
|
this._sceneTransition.render();
|
||||||
|
}
|
||||||
|
} else if (this._scene) {
|
||||||
|
this._scene.render();
|
||||||
|
|
||||||
|
Debug.render();
|
||||||
|
|
||||||
|
// 如果我们没有一个活跃的场景转换,就像平常一样渲染
|
||||||
|
this._scene.postRender();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public startDebugUpdate(){
|
||||||
|
TimeRuler.Instance.startFrame();
|
||||||
|
TimeRuler.Instance.beginMark("update", 0x00FF00);
|
||||||
|
}
|
||||||
|
|
||||||
|
public endDebugUpdate(){
|
||||||
|
TimeRuler.Instance.endMark("update");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 在一个场景结束后,下一个场景开始之前调用
|
||||||
|
*/
|
||||||
|
public onSceneChanged(){
|
||||||
|
Core.emitter.emit(CoreEvents.SceneChanged);
|
||||||
|
Time.sceneChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 临时运行SceneTransition,允许一个场景过渡到另一个平滑的自定义效果。
|
||||||
|
* @param sceneTransition
|
||||||
|
*/
|
||||||
|
public static startSceneTransition<T extends SceneTransition>(sceneTransition: T): T {
|
||||||
|
if (this._instance._sceneTransition) {
|
||||||
|
console.warn("在前一个场景完成之前,不能开始一个新的场景转换。");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this._instance._sceneTransition = sceneTransition;
|
||||||
|
return sceneTransition;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static registerActiveSceneChanged(current: Scene, next: Scene){
|
||||||
|
if (this.activeSceneChanged)
|
||||||
|
this.activeSceneChanged(current, next);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加一个全局管理器对象,它的更新方法将调用场景前的每一帧。
|
||||||
|
* @param manager
|
||||||
|
*/
|
||||||
|
public static registerGlobalManager(manager: es.GlobalManager){
|
||||||
|
this._instance._globalManagers.push(manager);
|
||||||
|
manager.enabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除全局管理器对象
|
||||||
|
* @param manager
|
||||||
|
*/
|
||||||
|
public static unregisterGlobalManager(manager: es.GlobalManager){
|
||||||
|
this._instance._globalManagers.remove(manager);
|
||||||
|
manager.enabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取类型为T的全局管理器
|
||||||
|
* @param type
|
||||||
|
*/
|
||||||
|
public static getGlobalManager<T extends es.GlobalManager>(type): T {
|
||||||
|
for (let i = 0; i < this._instance._globalManagers.length; i ++){
|
||||||
|
if (this._instance._globalManagers[i] instanceof type)
|
||||||
|
return this._instance._globalManagers[i] as T;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,16 @@
|
|||||||
module es {
|
module es {
|
||||||
export enum CoreEvents{
|
export enum CoreEvents{
|
||||||
/** 当场景发生变化时触发 */
|
/**
|
||||||
|
* 在图形设备重置时触发。当这种情况发生时,任何渲染目标或其他内容的VRAM将被擦除,需要重新生成
|
||||||
|
*/
|
||||||
|
GraphicsDeviceReset,
|
||||||
|
/**
|
||||||
|
* 当场景发生变化时触发
|
||||||
|
*/
|
||||||
SceneChanged,
|
SceneChanged,
|
||||||
|
/**
|
||||||
|
* 当设备方向改变时触发
|
||||||
|
*/
|
||||||
|
OrientationChanged,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,9 +48,6 @@ module es {
|
|||||||
|
|
||||||
this.entityProcessors = new EntityProcessorList();
|
this.entityProcessors = new EntityProcessorList();
|
||||||
|
|
||||||
this.width = SceneManager.stage.stageWidth;
|
|
||||||
this.height = SceneManager.stage.stageHeight;
|
|
||||||
|
|
||||||
this.initialize();
|
this.initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,13 +78,6 @@ module es {
|
|||||||
public onDeactive() {}
|
public onDeactive() {}
|
||||||
|
|
||||||
public async begin() {
|
public async begin() {
|
||||||
// 如果是场景转换需要在最顶层
|
|
||||||
if (SceneManager.sceneTransition){
|
|
||||||
SceneManager.stage.addChildAt(this, SceneManager.stage.numChildren - 1);
|
|
||||||
}else{
|
|
||||||
SceneManager.stage.addChild(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this._renderers.length == 0) {
|
if (this._renderers.length == 0) {
|
||||||
this.addRenderer(new DefaultRenderer());
|
this.addRenderer(new DefaultRenderer());
|
||||||
console.warn("场景开始时没有渲染器 自动添加DefaultRenderer以保证能够正常渲染");
|
console.warn("场景开始时没有渲染器 自动添加DefaultRenderer以保证能够正常渲染");
|
||||||
|
|||||||
@@ -1,146 +0,0 @@
|
|||||||
module es {
|
|
||||||
/** 运行时的场景管理。 */
|
|
||||||
export class SceneManager {
|
|
||||||
private static _scene: Scene;
|
|
||||||
private static _nextScene: Scene;
|
|
||||||
public static sceneTransition: SceneTransition;
|
|
||||||
public static stage: egret.Stage;
|
|
||||||
/** 订阅此事件以在活动场景发生更改时得到通知。 */
|
|
||||||
public static activeSceneChanged: Function;
|
|
||||||
/** 核心发射器。只发出核心级别的事件 */
|
|
||||||
public static emitter: Emitter<CoreEvents>;
|
|
||||||
/** 全局内容管理器加载任何应该停留在场景之间的资产 */
|
|
||||||
public static content: ContentManager;
|
|
||||||
/** 简化对内部类的全局内容实例的访问 */
|
|
||||||
private static _instnace: SceneManager;
|
|
||||||
private static timerRuler: TimeRuler;
|
|
||||||
public static get Instance(){
|
|
||||||
return this._instnace;
|
|
||||||
}
|
|
||||||
|
|
||||||
constructor(stage: egret.Stage) {
|
|
||||||
stage.addEventListener(egret.Event.ENTER_FRAME, SceneManager.update, this);
|
|
||||||
|
|
||||||
SceneManager._instnace = this;
|
|
||||||
SceneManager.emitter = new Emitter<CoreEvents>();
|
|
||||||
SceneManager.content = new ContentManager();
|
|
||||||
|
|
||||||
SceneManager.stage = stage;
|
|
||||||
SceneManager.initialize(stage);
|
|
||||||
SceneManager.timerRuler = new TimeRuler();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static get scene() {
|
|
||||||
return this._scene;
|
|
||||||
}
|
|
||||||
public static set scene(value: Scene) {
|
|
||||||
if (!value)
|
|
||||||
throw new Error("场景不能为空");
|
|
||||||
|
|
||||||
if (this._scene == null) {
|
|
||||||
this._scene = value;
|
|
||||||
this._scene.begin();
|
|
||||||
SceneManager.Instance.onSceneChanged();
|
|
||||||
} else {
|
|
||||||
this._nextScene = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.registerActiveSceneChanged(this._scene, this._nextScene);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static initialize(stage: egret.Stage) {
|
|
||||||
Input.initialize(stage);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static update() {
|
|
||||||
SceneManager.startDebugUpdate();
|
|
||||||
Time.update(egret.getTimer());
|
|
||||||
|
|
||||||
if (SceneManager._scene) {
|
|
||||||
for (let i = GlobalManager.globalManagers.length - 1; i >= 0; i--) {
|
|
||||||
if (GlobalManager.globalManagers[i].enabled)
|
|
||||||
GlobalManager.globalManagers[i].update();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!SceneManager.sceneTransition ||
|
|
||||||
(SceneManager.sceneTransition && (!SceneManager.sceneTransition.loadsNewScene || SceneManager.sceneTransition.isNewSceneLoaded))) {
|
|
||||||
SceneManager._scene.update();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (SceneManager._nextScene) {
|
|
||||||
SceneManager._scene.end();
|
|
||||||
|
|
||||||
SceneManager._scene = SceneManager._nextScene;
|
|
||||||
SceneManager._nextScene = null;
|
|
||||||
SceneManager._instnace.onSceneChanged();
|
|
||||||
|
|
||||||
SceneManager._scene.begin();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SceneManager.endDebugUpdate();
|
|
||||||
SceneManager.render();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static render() {
|
|
||||||
if (this.sceneTransition){
|
|
||||||
this.sceneTransition.preRender();
|
|
||||||
|
|
||||||
if (this._scene && !this.sceneTransition.hasPreviousSceneRender){
|
|
||||||
this._scene.render();
|
|
||||||
this._scene.postRender();
|
|
||||||
this.sceneTransition.onBeginTransition();
|
|
||||||
} else if (this.sceneTransition) {
|
|
||||||
if (this._scene && this.sceneTransition.isNewSceneLoaded) {
|
|
||||||
this._scene.render();
|
|
||||||
this._scene.postRender();
|
|
||||||
}
|
|
||||||
|
|
||||||
this.sceneTransition.render();
|
|
||||||
}
|
|
||||||
} else if (this._scene) {
|
|
||||||
this._scene.render();
|
|
||||||
|
|
||||||
Debug.render();
|
|
||||||
|
|
||||||
this._scene.postRender();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 临时运行SceneTransition,允许一个场景过渡到另一个平滑的自定义效果。
|
|
||||||
* @param sceneTransition
|
|
||||||
*/
|
|
||||||
public static startSceneTransition<T extends SceneTransition>(sceneTransition: T): T {
|
|
||||||
if (this.sceneTransition) {
|
|
||||||
console.warn("在前一个场景完成之前,不能开始一个新的场景转换。");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.sceneTransition = sceneTransition;
|
|
||||||
return sceneTransition;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static registerActiveSceneChanged(current: Scene, next: Scene){
|
|
||||||
if (this.activeSceneChanged)
|
|
||||||
this.activeSceneChanged(current, next);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 在一个场景结束后,下一个场景开始之前调用
|
|
||||||
*/
|
|
||||||
public onSceneChanged(){
|
|
||||||
SceneManager.emitter.emit(CoreEvents.SceneChanged);
|
|
||||||
Time.sceneChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static startDebugUpdate(){
|
|
||||||
TimeRuler.Instance.startFrame();
|
|
||||||
TimeRuler.Instance.beginMark("update", 0x00FF00);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static endDebugUpdate(){
|
|
||||||
TimeRuler.Instance.endMark("update");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -78,7 +78,7 @@ module es {
|
|||||||
let offsetY: number = Math.round(bitmapData.$offsetY);
|
let offsetY: number = Math.round(bitmapData.$offsetY);
|
||||||
let bitmapWidth: number = bitmapData.$bitmapWidth;
|
let bitmapWidth: number = bitmapData.$bitmapWidth;
|
||||||
let bitmapHeight: number = bitmapData.$bitmapHeight;
|
let bitmapHeight: number = bitmapData.$bitmapHeight;
|
||||||
let $TextureScaleFactor = SceneManager.stage.textureScaleFactor;
|
let $TextureScaleFactor = Core._instance.stage.textureScaleFactor;
|
||||||
this.sharedContext.drawImage(bitmapData.$bitmapData.source, bitmapData.$bitmapX + rect.x / $TextureScaleFactor, bitmapData.$bitmapY + rect.y / $TextureScaleFactor,
|
this.sharedContext.drawImage(bitmapData.$bitmapData.source, bitmapData.$bitmapX + rect.x / $TextureScaleFactor, bitmapData.$bitmapY + rect.y / $TextureScaleFactor,
|
||||||
bitmapWidth * rect.width / w, bitmapHeight * rect.height / h, offsetX, offsetY, rect.width, rect.height);
|
bitmapWidth * rect.width / w, bitmapHeight * rect.height / h, offsetX, offsetY, rect.width, rect.height);
|
||||||
return surface;
|
return surface;
|
||||||
|
|||||||
@@ -66,8 +66,8 @@ module es {
|
|||||||
|
|
||||||
constructor(){
|
constructor(){
|
||||||
super(PostProcessor.default_vert, GaussianBlurEffect.blur_frag,{
|
super(PostProcessor.default_vert, GaussianBlurEffect.blur_frag,{
|
||||||
screenWidth: SceneManager.stage.stageWidth,
|
screenWidth: Core.graphicsDevice.viewport.width,
|
||||||
screenHeight: SceneManager.stage.stageHeight
|
screenHeight: Core.graphicsDevice.viewport.height
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,20 @@
|
|||||||
module es {
|
module es {
|
||||||
export class GraphicsDevice {
|
export class GraphicsDevice {
|
||||||
private viewport: Viewport;
|
private _viewport: Viewport;
|
||||||
|
public get viewport(): Viewport{
|
||||||
|
return this._viewport;
|
||||||
|
}
|
||||||
|
|
||||||
public graphicsCapabilities: GraphicsCapabilities;
|
public graphicsCapabilities: GraphicsCapabilities;
|
||||||
|
|
||||||
constructor(){
|
constructor(){
|
||||||
|
this.setup();
|
||||||
this.graphicsCapabilities = new GraphicsCapabilities();
|
this.graphicsCapabilities = new GraphicsCapabilities();
|
||||||
this.graphicsCapabilities.initialize(this);
|
this.graphicsCapabilities.initialize(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private setup(){
|
||||||
|
this._viewport = new Viewport(0, 0, Core._instance.stage.stageWidth, Core._instance.stage.stageHeight);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ module es {
|
|||||||
this.scene = scene;
|
this.scene = scene;
|
||||||
this.shape = new egret.Shape();
|
this.shape = new egret.Shape();
|
||||||
this.shape.graphics.beginFill(0xFFFFFF, 1);
|
this.shape.graphics.beginFill(0xFFFFFF, 1);
|
||||||
this.shape.graphics.drawRect(0, 0, SceneManager.stage.stageWidth, SceneManager.stage.stageHeight);
|
this.shape.graphics.drawRect(0, 0, Core.graphicsDevice.viewport.width, Core.graphicsDevice.viewport.height);
|
||||||
this.shape.graphics.endFill();
|
this.shape.graphics.endFill();
|
||||||
scene.addChild(this.shape);
|
scene.addChild(this.shape);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,9 +15,8 @@ module es {
|
|||||||
|
|
||||||
public async onBeginTransition() {
|
public async onBeginTransition() {
|
||||||
this._mask.graphics.beginFill(this.fadeToColor, 1);
|
this._mask.graphics.beginFill(this.fadeToColor, 1);
|
||||||
this._mask.graphics.drawRect(0, 0, SceneManager.stage.stageWidth, SceneManager.stage.stageHeight);
|
this._mask.graphics.drawRect(0, 0, Core.graphicsDevice.viewport.width, Core.graphicsDevice.viewport.height);
|
||||||
this._mask.graphics.endFill();
|
this._mask.graphics.endFill();
|
||||||
SceneManager.stage.addChild(this._mask);
|
|
||||||
|
|
||||||
egret.Tween.get(this).to({ _alpha: 1}, this.fadeOutDuration * 1000, this.fadeEaseType)
|
egret.Tween.get(this).to({ _alpha: 1}, this.fadeOutDuration * 1000, this.fadeEaseType)
|
||||||
.call(async () => {
|
.call(async () => {
|
||||||
@@ -25,7 +24,6 @@ module es {
|
|||||||
}).wait(this.delayBeforeFadeInDuration).call(() => {
|
}).wait(this.delayBeforeFadeInDuration).call(() => {
|
||||||
egret.Tween.get(this).to({ _alpha: 0 }, this.fadeOutDuration * 1000, this.fadeEaseType).call(() => {
|
egret.Tween.get(this).to({ _alpha: 0 }, this.fadeOutDuration * 1000, this.fadeEaseType).call(() => {
|
||||||
this.transitionComplete();
|
this.transitionComplete();
|
||||||
SceneManager.stage.removeChild(this._mask);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -33,7 +31,7 @@ module es {
|
|||||||
public render(){
|
public render(){
|
||||||
this._mask.graphics.clear();
|
this._mask.graphics.clear();
|
||||||
this._mask.graphics.beginFill(this.fadeToColor, this._alpha);
|
this._mask.graphics.beginFill(this.fadeToColor, this._alpha);
|
||||||
this._mask.graphics.drawRect(0, 0, SceneManager.stage.stageWidth, SceneManager.stage.stageHeight);
|
this._mask.graphics.drawRect(0, 0, Core.graphicsDevice.viewport.width, Core.graphicsDevice.viewport.height);
|
||||||
this._mask.graphics.endFill();
|
this._mask.graphics.endFill();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ module es {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected transitionComplete() {
|
protected transitionComplete() {
|
||||||
SceneManager.sceneTransition = null;
|
Core._instance._sceneTransition = null;
|
||||||
|
|
||||||
if (this.onTransitionCompleted) {
|
if (this.onTransitionCompleted) {
|
||||||
this.onTransitionCompleted();
|
this.onTransitionCompleted();
|
||||||
@@ -59,7 +59,7 @@ module es {
|
|||||||
this.isNewSceneLoaded = true;
|
this.isNewSceneLoaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneManager.scene = await this.sceneLoadAction();
|
Core.scene = await this.sceneLoadAction();
|
||||||
this.isNewSceneLoaded = true;
|
this.isNewSceneLoaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,17 +51,15 @@ module es {
|
|||||||
|
|
||||||
this._mask = new egret.Shape();
|
this._mask = new egret.Shape();
|
||||||
this._mask.graphics.beginFill(0xFFFFFF, 1);
|
this._mask.graphics.beginFill(0xFFFFFF, 1);
|
||||||
this._mask.graphics.drawRect(0, 0, SceneManager.stage.stageWidth, SceneManager.stage.stageHeight);
|
this._mask.graphics.drawRect(0, 0, Core.graphicsDevice.viewport.width, Core.graphicsDevice.viewport.height);
|
||||||
this._mask.graphics.endFill();
|
this._mask.graphics.endFill();
|
||||||
this._mask.filters = [this._windEffect];
|
this._mask.filters = [this._windEffect];
|
||||||
SceneManager.stage.addChild(this._mask);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async onBeginTransition() {
|
public async onBeginTransition() {
|
||||||
this.loadNextScene();
|
this.loadNextScene();
|
||||||
await this.tickEffectProgressProperty(this._windEffect, this.duration, this.easeType);
|
await this.tickEffectProgressProperty(this._windEffect, this.duration, this.easeType);
|
||||||
this.transitionComplete();
|
this.transitionComplete();
|
||||||
SceneManager.stage.removeChild(this._mask);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,20 @@ module es {
|
|||||||
private _minDepth: number;
|
private _minDepth: number;
|
||||||
private _maxDepth: number;
|
private _maxDepth: number;
|
||||||
|
|
||||||
|
public get height(){
|
||||||
|
return this._height;
|
||||||
|
}
|
||||||
|
public set height(value: number){
|
||||||
|
this._height = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public get width(){
|
||||||
|
return this._width;
|
||||||
|
}
|
||||||
|
public set width(value: number){
|
||||||
|
this._width = value;
|
||||||
|
}
|
||||||
|
|
||||||
public get aspectRatio(){
|
public get aspectRatio(){
|
||||||
if ((this._height != 0) && (this._width != 0))
|
if ((this._height != 0) && (this._width != 0))
|
||||||
return (this._width / this._height);
|
return (this._width / this._height);
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ module es {
|
|||||||
public safeArea: Rectangle;
|
public safeArea: Rectangle;
|
||||||
|
|
||||||
constructor(){
|
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;
|
this.safeArea = this.clientArea;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,9 @@ module es {
|
|||||||
this._logs[i] = new FrameLog();
|
this._logs[i] = new FrameLog();
|
||||||
|
|
||||||
this.sampleFrames = this.targetSampleFrames = 1;
|
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();
|
this.onGraphicsDeviceReset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,26 @@
|
|||||||
module es {
|
module es {
|
||||||
export class GlobalManager {
|
export class GlobalManager {
|
||||||
public static globalManagers: GlobalManager[] = [];
|
/**
|
||||||
private _enabled: boolean;
|
* 如果true则启用了GlobalManager。
|
||||||
|
* 状态的改变会导致调用OnEnabled/OnDisable
|
||||||
|
*/
|
||||||
public get enabled(){
|
public get enabled(){
|
||||||
return this._enabled;
|
return this._enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 如果true则启用了GlobalManager。
|
||||||
|
* 状态的改变会导致调用OnEnabled/OnDisable
|
||||||
|
* @param value
|
||||||
|
*/
|
||||||
public set enabled(value: boolean){
|
public set enabled(value: boolean){
|
||||||
this.setEnabled(value);
|
this.setEnabled(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 启用/禁用这个GlobalManager
|
||||||
|
* @param isEnabled
|
||||||
|
*/
|
||||||
public setEnabled(isEnabled: boolean){
|
public setEnabled(isEnabled: boolean){
|
||||||
if (this._enabled != isEnabled){
|
if (this._enabled != isEnabled){
|
||||||
this._enabled = isEnabled;
|
this._enabled = isEnabled;
|
||||||
@@ -19,30 +31,21 @@ module es {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public _enabled: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 此GlobalManager启用时调用
|
||||||
|
*/
|
||||||
public onEnabled(){}
|
public onEnabled(){}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 此GlobalManager禁用时调用
|
||||||
|
*/
|
||||||
public onDisabled(){}
|
public onDisabled(){}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 在frame .update之前调用每一帧
|
||||||
|
*/
|
||||||
public 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 {
|
export class Input {
|
||||||
private static _init: boolean = false;
|
private static _init: boolean = false;
|
||||||
private static _stage: egret.Stage;
|
|
||||||
private static _previousTouchState: TouchState = new TouchState();
|
private static _previousTouchState: TouchState = new TouchState();
|
||||||
private static _gameTouchs: TouchState[] = [];
|
private static _gameTouchs: TouchState[] = [];
|
||||||
private static _resolutionOffset: Vector2 = new Vector2();
|
private static _resolutionOffset: Vector2 = new Vector2();
|
||||||
@@ -33,13 +32,13 @@ module es {
|
|||||||
}
|
}
|
||||||
/** 获取最大触摸数 */
|
/** 获取最大触摸数 */
|
||||||
public static get maxSupportedTouch(){
|
public static get maxSupportedTouch(){
|
||||||
return this._stage.maxTouches;
|
return Core._instance.stage.maxTouches;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 设置最大触摸数
|
* 设置最大触摸数
|
||||||
*/
|
*/
|
||||||
public static set maxSupportedTouch(value: number){
|
public static set maxSupportedTouch(value: number){
|
||||||
this._stage.maxTouches = value;
|
Core._instance.stage.maxTouches = value;
|
||||||
this.initTouchCache();
|
this.initTouchCache();
|
||||||
}
|
}
|
||||||
/** 获取缩放值 默认为1 */
|
/** 获取缩放值 默认为1 */
|
||||||
@@ -68,17 +67,16 @@ module es {
|
|||||||
return delta;
|
return delta;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static initialize(stage: egret.Stage){
|
public static initialize(){
|
||||||
if (this._init)
|
if (this._init)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this._init = true;
|
this._init = true;
|
||||||
this._stage = stage;
|
Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.touchBegin, this);
|
||||||
this._stage.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.touchBegin, this);
|
Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_MOVE, this.touchMove, this);
|
||||||
this._stage.addEventListener(egret.TouchEvent.TOUCH_MOVE, this.touchMove, this);
|
Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_END, this.touchEnd, this);
|
||||||
this._stage.addEventListener(egret.TouchEvent.TOUCH_END, this.touchEnd, this);
|
Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_CANCEL, this.touchEnd, this);
|
||||||
this._stage.addEventListener(egret.TouchEvent.TOUCH_CANCEL, this.touchEnd, this);
|
Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_RELEASE_OUTSIDE, this.touchEnd, this);
|
||||||
this._stage.addEventListener(egret.TouchEvent.TOUCH_RELEASE_OUTSIDE, this.touchEnd, this);
|
|
||||||
|
|
||||||
this.initTouchCache();
|
this.initTouchCache();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user