Vendored
+10
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"version": "0.1.0",
|
||||||
|
"command": "egret",
|
||||||
|
"isShellCommand": true,
|
||||||
|
"showOutput": "silent",
|
||||||
|
"args": [
|
||||||
|
"build"
|
||||||
|
],
|
||||||
|
"problemMatcher": "$tsc"
|
||||||
|
}
|
||||||
Vendored
-2452
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Vendored
-1
File diff suppressed because one or more lines are too long
Vendored
+40
-25
@@ -143,6 +143,7 @@ declare abstract class Component extends egret.DisplayObjectContainer {
|
|||||||
entity: Entity;
|
entity: Entity;
|
||||||
private _enabled;
|
private _enabled;
|
||||||
updateInterval: number;
|
updateInterval: number;
|
||||||
|
userData: any;
|
||||||
enabled: boolean;
|
enabled: boolean;
|
||||||
setEnabled(isEnabled: boolean): this;
|
setEnabled(isEnabled: boolean): this;
|
||||||
initialize(): void;
|
initialize(): void;
|
||||||
@@ -318,12 +319,18 @@ declare class Sprite {
|
|||||||
readonly uvs: Rectangle;
|
readonly uvs: Rectangle;
|
||||||
constructor(texture: egret.Texture, sourceRect?: Rectangle, origin?: Vector2);
|
constructor(texture: egret.Texture, sourceRect?: Rectangle, origin?: Vector2);
|
||||||
}
|
}
|
||||||
|
declare class SpriteAnimation {
|
||||||
|
readonly sprites: Sprite[];
|
||||||
|
readonly frameRate: number;
|
||||||
|
constructor(sprites: Sprite[], frameRate: number);
|
||||||
|
}
|
||||||
declare class SpriteRenderer extends RenderableComponent {
|
declare class SpriteRenderer extends RenderableComponent {
|
||||||
private _origin;
|
private _origin;
|
||||||
private _bitmap;
|
private _bitmap;
|
||||||
private _sprite;
|
private _sprite;
|
||||||
origin: Vector2;
|
origin: Vector2;
|
||||||
setOrigin(origin: Vector2): this;
|
setOrigin(origin: Vector2): this;
|
||||||
|
sprite: Sprite;
|
||||||
setSprite(sprite: Sprite): SpriteRenderer;
|
setSprite(sprite: Sprite): SpriteRenderer;
|
||||||
setColor(color: number): SpriteRenderer;
|
setColor(color: number): SpriteRenderer;
|
||||||
isVisibleFromCamera(camera: Camera): boolean;
|
isVisibleFromCamera(camera: Camera): boolean;
|
||||||
@@ -331,6 +338,39 @@ declare class SpriteRenderer extends RenderableComponent {
|
|||||||
onRemovedFromEntity(): void;
|
onRemovedFromEntity(): void;
|
||||||
reset(): void;
|
reset(): void;
|
||||||
}
|
}
|
||||||
|
declare class SpriteAnimator extends SpriteRenderer {
|
||||||
|
onAnimationCompletedEvent: Function;
|
||||||
|
speed: number;
|
||||||
|
animationState: State;
|
||||||
|
currentAnimation: SpriteAnimation;
|
||||||
|
currentAnimationName: string;
|
||||||
|
currentFrame: number;
|
||||||
|
readonly isRunning: boolean;
|
||||||
|
private _animations;
|
||||||
|
private _elapsedTime;
|
||||||
|
private _loopMode;
|
||||||
|
constructor(sprite?: Sprite);
|
||||||
|
addAnimation(name: string, animation: SpriteAnimation): SpriteAnimator;
|
||||||
|
play(name: string, loopMode?: LoopMode): void;
|
||||||
|
isAnimationActive(name: string): boolean;
|
||||||
|
pause(): void;
|
||||||
|
unPause(): void;
|
||||||
|
stop(): void;
|
||||||
|
update(): void;
|
||||||
|
}
|
||||||
|
declare enum LoopMode {
|
||||||
|
loop = 0,
|
||||||
|
once = 1,
|
||||||
|
clampForever = 2,
|
||||||
|
pingPong = 3,
|
||||||
|
pingPongOnce = 4
|
||||||
|
}
|
||||||
|
declare enum State {
|
||||||
|
none = 0,
|
||||||
|
running = 1,
|
||||||
|
paused = 2,
|
||||||
|
completed = 3
|
||||||
|
}
|
||||||
interface ITriggerListener {
|
interface ITriggerListener {
|
||||||
onTriggerEnter(other: Collider, local: Collider): any;
|
onTriggerEnter(other: Collider, local: Collider): any;
|
||||||
onTriggerExit(other: Collider, local: Collider): any;
|
onTriggerExit(other: Collider, local: Collider): any;
|
||||||
@@ -644,31 +684,6 @@ declare class WindTransition extends SceneTransition {
|
|||||||
constructor(sceneLoadAction: Function);
|
constructor(sceneLoadAction: Function);
|
||||||
onBeginTransition(): Promise<void>;
|
onBeginTransition(): Promise<void>;
|
||||||
}
|
}
|
||||||
declare class BaseView extends egret.DisplayObjectContainer {
|
|
||||||
protected _data: any;
|
|
||||||
protected init(): void;
|
|
||||||
show(data?: any): void;
|
|
||||||
refreshData(data?: any): void;
|
|
||||||
refreshView(): void;
|
|
||||||
close(): void;
|
|
||||||
destroy(): void;
|
|
||||||
}
|
|
||||||
declare class BaseFuiView extends BaseView {
|
|
||||||
protected _name: string;
|
|
||||||
constructor(name: string);
|
|
||||||
}
|
|
||||||
declare class BaseSingle {
|
|
||||||
private static _instance;
|
|
||||||
static getInstance<T>(): T;
|
|
||||||
protected clearFuiObj(obj: fairygui.GObject): boolean;
|
|
||||||
}
|
|
||||||
declare class ViewManager extends BaseSingle {
|
|
||||||
private _openDic;
|
|
||||||
refreshView(viewClass: any, data?: any): void;
|
|
||||||
openView(viewClass: any, data?: any, complete?: Function): void;
|
|
||||||
getView<T>(viewClass: any): T;
|
|
||||||
existView(viewClass: any): boolean;
|
|
||||||
}
|
|
||||||
declare class Flags {
|
declare class Flags {
|
||||||
static isFlagSet(self: number, flag: number): boolean;
|
static isFlagSet(self: number, flag: number): boolean;
|
||||||
static isUnshiftedFlagSet(self: number, flag: number): boolean;
|
static isUnshiftedFlagSet(self: number, flag: number): boolean;
|
||||||
|
|||||||
@@ -1566,6 +1566,13 @@ var Sprite = (function () {
|
|||||||
}
|
}
|
||||||
return Sprite;
|
return Sprite;
|
||||||
}());
|
}());
|
||||||
|
var SpriteAnimation = (function () {
|
||||||
|
function SpriteAnimation(sprites, frameRate) {
|
||||||
|
this.sprites = sprites;
|
||||||
|
this.frameRate = frameRate;
|
||||||
|
}
|
||||||
|
return SpriteAnimation;
|
||||||
|
}());
|
||||||
var SpriteRenderer = (function (_super) {
|
var SpriteRenderer = (function (_super) {
|
||||||
__extends(SpriteRenderer, _super);
|
__extends(SpriteRenderer, _super);
|
||||||
function SpriteRenderer() {
|
function SpriteRenderer() {
|
||||||
@@ -1587,6 +1594,16 @@ var SpriteRenderer = (function (_super) {
|
|||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
Object.defineProperty(SpriteRenderer.prototype, "sprite", {
|
||||||
|
get: function () {
|
||||||
|
return this._sprite;
|
||||||
|
},
|
||||||
|
set: function (value) {
|
||||||
|
this.setSprite(value);
|
||||||
|
},
|
||||||
|
enumerable: true,
|
||||||
|
configurable: true
|
||||||
|
});
|
||||||
SpriteRenderer.prototype.setSprite = function (sprite) {
|
SpriteRenderer.prototype.setSprite = function (sprite) {
|
||||||
this.removeChildren();
|
this.removeChildren();
|
||||||
this._sprite = sprite;
|
this._sprite = sprite;
|
||||||
@@ -1627,6 +1644,100 @@ var SpriteRenderer = (function (_super) {
|
|||||||
};
|
};
|
||||||
return SpriteRenderer;
|
return SpriteRenderer;
|
||||||
}(RenderableComponent));
|
}(RenderableComponent));
|
||||||
|
var SpriteAnimator = (function (_super) {
|
||||||
|
__extends(SpriteAnimator, _super);
|
||||||
|
function SpriteAnimator(sprite) {
|
||||||
|
var _this = _super.call(this) || this;
|
||||||
|
_this.speed = 1;
|
||||||
|
_this.animationState = State.none;
|
||||||
|
_this._animations = new Map();
|
||||||
|
_this._elapsedTime = 0;
|
||||||
|
if (sprite)
|
||||||
|
_this.setSprite(sprite);
|
||||||
|
return _this;
|
||||||
|
}
|
||||||
|
Object.defineProperty(SpriteAnimator.prototype, "isRunning", {
|
||||||
|
get: function () {
|
||||||
|
return this.animationState == State.running;
|
||||||
|
},
|
||||||
|
enumerable: true,
|
||||||
|
configurable: true
|
||||||
|
});
|
||||||
|
SpriteAnimator.prototype.addAnimation = function (name, animation) {
|
||||||
|
if (!this.sprite && animation.sprites.length > 0)
|
||||||
|
this.setSprite(animation.sprites[0]);
|
||||||
|
this._animations[name] = animation;
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
SpriteAnimator.prototype.play = function (name, loopMode) {
|
||||||
|
if (loopMode === void 0) { loopMode = null; }
|
||||||
|
this.currentAnimation = this._animations[name];
|
||||||
|
this.currentAnimationName = name;
|
||||||
|
this.currentFrame = 0;
|
||||||
|
this.animationState = State.running;
|
||||||
|
this.sprite = this.currentAnimation.sprites[0];
|
||||||
|
this._elapsedTime = 0;
|
||||||
|
this._loopMode = loopMode ? loopMode : LoopMode.loop;
|
||||||
|
};
|
||||||
|
SpriteAnimator.prototype.isAnimationActive = function (name) {
|
||||||
|
return this.currentAnimation && this.currentAnimationName == name;
|
||||||
|
};
|
||||||
|
SpriteAnimator.prototype.pause = function () {
|
||||||
|
this.animationState = State.paused;
|
||||||
|
};
|
||||||
|
SpriteAnimator.prototype.unPause = function () {
|
||||||
|
this.animationState = State.running;
|
||||||
|
};
|
||||||
|
SpriteAnimator.prototype.stop = function () {
|
||||||
|
this.currentAnimation = null;
|
||||||
|
this.currentAnimationName = null;
|
||||||
|
this.currentFrame = 0;
|
||||||
|
this.animationState = State.none;
|
||||||
|
};
|
||||||
|
SpriteAnimator.prototype.update = function () {
|
||||||
|
if (this.animationState != State.running || !this.currentAnimation)
|
||||||
|
return;
|
||||||
|
var animation = this.currentAnimation;
|
||||||
|
var secondsPerFrame = 1 / (animation.frameRate * this.speed);
|
||||||
|
var iterationDuration = secondsPerFrame * animation.sprites.length;
|
||||||
|
this._elapsedTime += Time.deltaTime;
|
||||||
|
var time = Math.abs(this._elapsedTime);
|
||||||
|
if (this._loopMode == LoopMode.once && time > iterationDuration ||
|
||||||
|
this._loopMode == LoopMode.pingPongOnce && time > iterationDuration * 2) {
|
||||||
|
this.animationState = State.completed;
|
||||||
|
this._elapsedTime = 0;
|
||||||
|
this.currentFrame = 0;
|
||||||
|
this.sprite = animation.sprites[this.currentFrame];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var i = Math.floor(time / secondsPerFrame);
|
||||||
|
var n = animation.sprites.length;
|
||||||
|
if (n > 2 && (this._loopMode == LoopMode.pingPong || this._loopMode == LoopMode.pingPongOnce)) {
|
||||||
|
var maxIndex = n - 1;
|
||||||
|
this.currentFrame = maxIndex - Math.abs(maxIndex - i % (maxIndex * 2));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.currentFrame = i % n;
|
||||||
|
}
|
||||||
|
this.sprite = animation.sprites[this.currentFrame];
|
||||||
|
};
|
||||||
|
return SpriteAnimator;
|
||||||
|
}(SpriteRenderer));
|
||||||
|
var LoopMode;
|
||||||
|
(function (LoopMode) {
|
||||||
|
LoopMode[LoopMode["loop"] = 0] = "loop";
|
||||||
|
LoopMode[LoopMode["once"] = 1] = "once";
|
||||||
|
LoopMode[LoopMode["clampForever"] = 2] = "clampForever";
|
||||||
|
LoopMode[LoopMode["pingPong"] = 3] = "pingPong";
|
||||||
|
LoopMode[LoopMode["pingPongOnce"] = 4] = "pingPongOnce";
|
||||||
|
})(LoopMode || (LoopMode = {}));
|
||||||
|
var State;
|
||||||
|
(function (State) {
|
||||||
|
State[State["none"] = 0] = "none";
|
||||||
|
State[State["running"] = 1] = "running";
|
||||||
|
State[State["paused"] = 2] = "paused";
|
||||||
|
State[State["completed"] = 3] = "completed";
|
||||||
|
})(State || (State = {}));
|
||||||
var Mover = (function (_super) {
|
var Mover = (function (_super) {
|
||||||
__extends(Mover, _super);
|
__extends(Mover, _super);
|
||||||
function Mover() {
|
function Mover() {
|
||||||
@@ -2968,103 +3079,6 @@ var WindTransition = (function (_super) {
|
|||||||
};
|
};
|
||||||
return WindTransition;
|
return WindTransition;
|
||||||
}(SceneTransition));
|
}(SceneTransition));
|
||||||
var BaseView = (function (_super) {
|
|
||||||
__extends(BaseView, _super);
|
|
||||||
function BaseView() {
|
|
||||||
return _super !== null && _super.apply(this, arguments) || this;
|
|
||||||
}
|
|
||||||
BaseView.prototype.init = function () {
|
|
||||||
};
|
|
||||||
BaseView.prototype.show = function (data) {
|
|
||||||
};
|
|
||||||
BaseView.prototype.refreshData = function (data) {
|
|
||||||
this._data = data;
|
|
||||||
};
|
|
||||||
BaseView.prototype.refreshView = function () {
|
|
||||||
};
|
|
||||||
BaseView.prototype.close = function () {
|
|
||||||
};
|
|
||||||
BaseView.prototype.destroy = function () {
|
|
||||||
if (this.parent) {
|
|
||||||
this.parent.removeChild(this);
|
|
||||||
}
|
|
||||||
while (this.numChildren > 0) {
|
|
||||||
this.removeChildAt(0);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
return BaseView;
|
|
||||||
}(egret.DisplayObjectContainer));
|
|
||||||
var BaseFuiView = (function (_super) {
|
|
||||||
__extends(BaseFuiView, _super);
|
|
||||||
function BaseFuiView(name) {
|
|
||||||
var _this = _super.call(this) || this;
|
|
||||||
_this.name = name;
|
|
||||||
return _this;
|
|
||||||
}
|
|
||||||
return BaseFuiView;
|
|
||||||
}(BaseView));
|
|
||||||
var BaseSingle = (function () {
|
|
||||||
function BaseSingle() {
|
|
||||||
}
|
|
||||||
BaseSingle.getInstance = function () {
|
|
||||||
if (this._instance == null) {
|
|
||||||
this._instance = new this();
|
|
||||||
}
|
|
||||||
return this._instance;
|
|
||||||
};
|
|
||||||
BaseSingle.prototype.clearFuiObj = function (obj) {
|
|
||||||
if (obj) {
|
|
||||||
egret.Tween.removeTweens(obj.displayObject);
|
|
||||||
if (obj.displayObject && obj.displayObject.parent) {
|
|
||||||
obj.displayObject.parent.removeChild(obj.displayObject);
|
|
||||||
}
|
|
||||||
obj.dispose();
|
|
||||||
obj = null;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
return BaseSingle;
|
|
||||||
}());
|
|
||||||
var ViewManager = (function (_super) {
|
|
||||||
__extends(ViewManager, _super);
|
|
||||||
function ViewManager() {
|
|
||||||
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
||||||
_this._openDic = [];
|
|
||||||
return _this;
|
|
||||||
}
|
|
||||||
ViewManager.prototype.refreshView = function (viewClass, data) {
|
|
||||||
var view = this.getView(viewClass);
|
|
||||||
if (view) {
|
|
||||||
view.refreshData(data);
|
|
||||||
view.refreshView();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
ViewManager.prototype.openView = function (viewClass, data, complete) {
|
|
||||||
var newView = this.getView(viewClass);
|
|
||||||
if (!newView) {
|
|
||||||
newView = new viewClass();
|
|
||||||
}
|
|
||||||
if (this.existView(viewClass)) {
|
|
||||||
newView.refreshData(data);
|
|
||||||
newView.refreshView();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this._openDic.push(newView);
|
|
||||||
};
|
|
||||||
ViewManager.prototype.getView = function (viewClass) {
|
|
||||||
var result = this._openDic.firstOrDefault(function (a) {
|
|
||||||
return a instanceof viewClass;
|
|
||||||
});
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
ViewManager.prototype.existView = function (viewClass) {
|
|
||||||
return this._openDic.findIndex(function (a) {
|
|
||||||
return a instanceof viewClass;
|
|
||||||
}) != -1;
|
|
||||||
};
|
|
||||||
return ViewManager;
|
|
||||||
}(BaseSingle));
|
|
||||||
var Flags = (function () {
|
var Flags = (function () {
|
||||||
function Flags() {
|
function Flags() {
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -132,9 +132,19 @@
|
|||||||
"name": "egret_icon_png"
|
"name": "egret_icon_png"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "description_json",
|
"url": "config/description.json",
|
||||||
"type": "json",
|
"type": "json",
|
||||||
"url": "config/description.json"
|
"name": "description_json"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "assets/isometric_grass_and_water.json",
|
||||||
|
"type": "json",
|
||||||
|
"name": "isometric_grass_and_water_json"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "assets/isometric_grass_and_water.png",
|
||||||
|
"type": "image",
|
||||||
|
"name": "isometric_grass_and_water_png"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
Vendored
+40
-25
@@ -143,6 +143,7 @@ declare abstract class Component extends egret.DisplayObjectContainer {
|
|||||||
entity: Entity;
|
entity: Entity;
|
||||||
private _enabled;
|
private _enabled;
|
||||||
updateInterval: number;
|
updateInterval: number;
|
||||||
|
userData: any;
|
||||||
enabled: boolean;
|
enabled: boolean;
|
||||||
setEnabled(isEnabled: boolean): this;
|
setEnabled(isEnabled: boolean): this;
|
||||||
initialize(): void;
|
initialize(): void;
|
||||||
@@ -318,12 +319,18 @@ declare class Sprite {
|
|||||||
readonly uvs: Rectangle;
|
readonly uvs: Rectangle;
|
||||||
constructor(texture: egret.Texture, sourceRect?: Rectangle, origin?: Vector2);
|
constructor(texture: egret.Texture, sourceRect?: Rectangle, origin?: Vector2);
|
||||||
}
|
}
|
||||||
|
declare class SpriteAnimation {
|
||||||
|
readonly sprites: Sprite[];
|
||||||
|
readonly frameRate: number;
|
||||||
|
constructor(sprites: Sprite[], frameRate: number);
|
||||||
|
}
|
||||||
declare class SpriteRenderer extends RenderableComponent {
|
declare class SpriteRenderer extends RenderableComponent {
|
||||||
private _origin;
|
private _origin;
|
||||||
private _bitmap;
|
private _bitmap;
|
||||||
private _sprite;
|
private _sprite;
|
||||||
origin: Vector2;
|
origin: Vector2;
|
||||||
setOrigin(origin: Vector2): this;
|
setOrigin(origin: Vector2): this;
|
||||||
|
sprite: Sprite;
|
||||||
setSprite(sprite: Sprite): SpriteRenderer;
|
setSprite(sprite: Sprite): SpriteRenderer;
|
||||||
setColor(color: number): SpriteRenderer;
|
setColor(color: number): SpriteRenderer;
|
||||||
isVisibleFromCamera(camera: Camera): boolean;
|
isVisibleFromCamera(camera: Camera): boolean;
|
||||||
@@ -331,6 +338,39 @@ declare class SpriteRenderer extends RenderableComponent {
|
|||||||
onRemovedFromEntity(): void;
|
onRemovedFromEntity(): void;
|
||||||
reset(): void;
|
reset(): void;
|
||||||
}
|
}
|
||||||
|
declare class SpriteAnimator extends SpriteRenderer {
|
||||||
|
onAnimationCompletedEvent: Function;
|
||||||
|
speed: number;
|
||||||
|
animationState: State;
|
||||||
|
currentAnimation: SpriteAnimation;
|
||||||
|
currentAnimationName: string;
|
||||||
|
currentFrame: number;
|
||||||
|
readonly isRunning: boolean;
|
||||||
|
private _animations;
|
||||||
|
private _elapsedTime;
|
||||||
|
private _loopMode;
|
||||||
|
constructor(sprite?: Sprite);
|
||||||
|
addAnimation(name: string, animation: SpriteAnimation): SpriteAnimator;
|
||||||
|
play(name: string, loopMode?: LoopMode): void;
|
||||||
|
isAnimationActive(name: string): boolean;
|
||||||
|
pause(): void;
|
||||||
|
unPause(): void;
|
||||||
|
stop(): void;
|
||||||
|
update(): void;
|
||||||
|
}
|
||||||
|
declare enum LoopMode {
|
||||||
|
loop = 0,
|
||||||
|
once = 1,
|
||||||
|
clampForever = 2,
|
||||||
|
pingPong = 3,
|
||||||
|
pingPongOnce = 4
|
||||||
|
}
|
||||||
|
declare enum State {
|
||||||
|
none = 0,
|
||||||
|
running = 1,
|
||||||
|
paused = 2,
|
||||||
|
completed = 3
|
||||||
|
}
|
||||||
interface ITriggerListener {
|
interface ITriggerListener {
|
||||||
onTriggerEnter(other: Collider, local: Collider): any;
|
onTriggerEnter(other: Collider, local: Collider): any;
|
||||||
onTriggerExit(other: Collider, local: Collider): any;
|
onTriggerExit(other: Collider, local: Collider): any;
|
||||||
@@ -644,31 +684,6 @@ declare class WindTransition extends SceneTransition {
|
|||||||
constructor(sceneLoadAction: Function);
|
constructor(sceneLoadAction: Function);
|
||||||
onBeginTransition(): Promise<void>;
|
onBeginTransition(): Promise<void>;
|
||||||
}
|
}
|
||||||
declare class BaseView extends egret.DisplayObjectContainer {
|
|
||||||
protected _data: any;
|
|
||||||
protected init(): void;
|
|
||||||
show(data?: any): void;
|
|
||||||
refreshData(data?: any): void;
|
|
||||||
refreshView(): void;
|
|
||||||
close(): void;
|
|
||||||
destroy(): void;
|
|
||||||
}
|
|
||||||
declare class BaseFuiView extends BaseView {
|
|
||||||
protected _name: string;
|
|
||||||
constructor(name: string);
|
|
||||||
}
|
|
||||||
declare class BaseSingle {
|
|
||||||
private static _instance;
|
|
||||||
static getInstance<T>(): T;
|
|
||||||
protected clearFuiObj(obj: fairygui.GObject): boolean;
|
|
||||||
}
|
|
||||||
declare class ViewManager extends BaseSingle {
|
|
||||||
private _openDic;
|
|
||||||
refreshView(viewClass: any, data?: any): void;
|
|
||||||
openView(viewClass: any, data?: any, complete?: Function): void;
|
|
||||||
getView<T>(viewClass: any): T;
|
|
||||||
existView(viewClass: any): boolean;
|
|
||||||
}
|
|
||||||
declare class Flags {
|
declare class Flags {
|
||||||
static isFlagSet(self: number, flag: number): boolean;
|
static isFlagSet(self: number, flag: number): boolean;
|
||||||
static isUnshiftedFlagSet(self: number, flag: number): boolean;
|
static isUnshiftedFlagSet(self: number, flag: number): boolean;
|
||||||
|
|||||||
+111
-97
@@ -1566,6 +1566,13 @@ var Sprite = (function () {
|
|||||||
}
|
}
|
||||||
return Sprite;
|
return Sprite;
|
||||||
}());
|
}());
|
||||||
|
var SpriteAnimation = (function () {
|
||||||
|
function SpriteAnimation(sprites, frameRate) {
|
||||||
|
this.sprites = sprites;
|
||||||
|
this.frameRate = frameRate;
|
||||||
|
}
|
||||||
|
return SpriteAnimation;
|
||||||
|
}());
|
||||||
var SpriteRenderer = (function (_super) {
|
var SpriteRenderer = (function (_super) {
|
||||||
__extends(SpriteRenderer, _super);
|
__extends(SpriteRenderer, _super);
|
||||||
function SpriteRenderer() {
|
function SpriteRenderer() {
|
||||||
@@ -1587,6 +1594,16 @@ var SpriteRenderer = (function (_super) {
|
|||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
Object.defineProperty(SpriteRenderer.prototype, "sprite", {
|
||||||
|
get: function () {
|
||||||
|
return this._sprite;
|
||||||
|
},
|
||||||
|
set: function (value) {
|
||||||
|
this.setSprite(value);
|
||||||
|
},
|
||||||
|
enumerable: true,
|
||||||
|
configurable: true
|
||||||
|
});
|
||||||
SpriteRenderer.prototype.setSprite = function (sprite) {
|
SpriteRenderer.prototype.setSprite = function (sprite) {
|
||||||
this.removeChildren();
|
this.removeChildren();
|
||||||
this._sprite = sprite;
|
this._sprite = sprite;
|
||||||
@@ -1627,6 +1644,100 @@ var SpriteRenderer = (function (_super) {
|
|||||||
};
|
};
|
||||||
return SpriteRenderer;
|
return SpriteRenderer;
|
||||||
}(RenderableComponent));
|
}(RenderableComponent));
|
||||||
|
var SpriteAnimator = (function (_super) {
|
||||||
|
__extends(SpriteAnimator, _super);
|
||||||
|
function SpriteAnimator(sprite) {
|
||||||
|
var _this = _super.call(this) || this;
|
||||||
|
_this.speed = 1;
|
||||||
|
_this.animationState = State.none;
|
||||||
|
_this._animations = new Map();
|
||||||
|
_this._elapsedTime = 0;
|
||||||
|
if (sprite)
|
||||||
|
_this.setSprite(sprite);
|
||||||
|
return _this;
|
||||||
|
}
|
||||||
|
Object.defineProperty(SpriteAnimator.prototype, "isRunning", {
|
||||||
|
get: function () {
|
||||||
|
return this.animationState == State.running;
|
||||||
|
},
|
||||||
|
enumerable: true,
|
||||||
|
configurable: true
|
||||||
|
});
|
||||||
|
SpriteAnimator.prototype.addAnimation = function (name, animation) {
|
||||||
|
if (!this.sprite && animation.sprites.length > 0)
|
||||||
|
this.setSprite(animation.sprites[0]);
|
||||||
|
this._animations[name] = animation;
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
SpriteAnimator.prototype.play = function (name, loopMode) {
|
||||||
|
if (loopMode === void 0) { loopMode = null; }
|
||||||
|
this.currentAnimation = this._animations[name];
|
||||||
|
this.currentAnimationName = name;
|
||||||
|
this.currentFrame = 0;
|
||||||
|
this.animationState = State.running;
|
||||||
|
this.sprite = this.currentAnimation.sprites[0];
|
||||||
|
this._elapsedTime = 0;
|
||||||
|
this._loopMode = loopMode ? loopMode : LoopMode.loop;
|
||||||
|
};
|
||||||
|
SpriteAnimator.prototype.isAnimationActive = function (name) {
|
||||||
|
return this.currentAnimation && this.currentAnimationName == name;
|
||||||
|
};
|
||||||
|
SpriteAnimator.prototype.pause = function () {
|
||||||
|
this.animationState = State.paused;
|
||||||
|
};
|
||||||
|
SpriteAnimator.prototype.unPause = function () {
|
||||||
|
this.animationState = State.running;
|
||||||
|
};
|
||||||
|
SpriteAnimator.prototype.stop = function () {
|
||||||
|
this.currentAnimation = null;
|
||||||
|
this.currentAnimationName = null;
|
||||||
|
this.currentFrame = 0;
|
||||||
|
this.animationState = State.none;
|
||||||
|
};
|
||||||
|
SpriteAnimator.prototype.update = function () {
|
||||||
|
if (this.animationState != State.running || !this.currentAnimation)
|
||||||
|
return;
|
||||||
|
var animation = this.currentAnimation;
|
||||||
|
var secondsPerFrame = 1 / (animation.frameRate * this.speed);
|
||||||
|
var iterationDuration = secondsPerFrame * animation.sprites.length;
|
||||||
|
this._elapsedTime += Time.deltaTime;
|
||||||
|
var time = Math.abs(this._elapsedTime);
|
||||||
|
if (this._loopMode == LoopMode.once && time > iterationDuration ||
|
||||||
|
this._loopMode == LoopMode.pingPongOnce && time > iterationDuration * 2) {
|
||||||
|
this.animationState = State.completed;
|
||||||
|
this._elapsedTime = 0;
|
||||||
|
this.currentFrame = 0;
|
||||||
|
this.sprite = animation.sprites[this.currentFrame];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var i = Math.floor(time / secondsPerFrame);
|
||||||
|
var n = animation.sprites.length;
|
||||||
|
if (n > 2 && (this._loopMode == LoopMode.pingPong || this._loopMode == LoopMode.pingPongOnce)) {
|
||||||
|
var maxIndex = n - 1;
|
||||||
|
this.currentFrame = maxIndex - Math.abs(maxIndex - i % (maxIndex * 2));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.currentFrame = i % n;
|
||||||
|
}
|
||||||
|
this.sprite = animation.sprites[this.currentFrame];
|
||||||
|
};
|
||||||
|
return SpriteAnimator;
|
||||||
|
}(SpriteRenderer));
|
||||||
|
var LoopMode;
|
||||||
|
(function (LoopMode) {
|
||||||
|
LoopMode[LoopMode["loop"] = 0] = "loop";
|
||||||
|
LoopMode[LoopMode["once"] = 1] = "once";
|
||||||
|
LoopMode[LoopMode["clampForever"] = 2] = "clampForever";
|
||||||
|
LoopMode[LoopMode["pingPong"] = 3] = "pingPong";
|
||||||
|
LoopMode[LoopMode["pingPongOnce"] = 4] = "pingPongOnce";
|
||||||
|
})(LoopMode || (LoopMode = {}));
|
||||||
|
var State;
|
||||||
|
(function (State) {
|
||||||
|
State[State["none"] = 0] = "none";
|
||||||
|
State[State["running"] = 1] = "running";
|
||||||
|
State[State["paused"] = 2] = "paused";
|
||||||
|
State[State["completed"] = 3] = "completed";
|
||||||
|
})(State || (State = {}));
|
||||||
var Mover = (function (_super) {
|
var Mover = (function (_super) {
|
||||||
__extends(Mover, _super);
|
__extends(Mover, _super);
|
||||||
function Mover() {
|
function Mover() {
|
||||||
@@ -2968,103 +3079,6 @@ var WindTransition = (function (_super) {
|
|||||||
};
|
};
|
||||||
return WindTransition;
|
return WindTransition;
|
||||||
}(SceneTransition));
|
}(SceneTransition));
|
||||||
var BaseView = (function (_super) {
|
|
||||||
__extends(BaseView, _super);
|
|
||||||
function BaseView() {
|
|
||||||
return _super !== null && _super.apply(this, arguments) || this;
|
|
||||||
}
|
|
||||||
BaseView.prototype.init = function () {
|
|
||||||
};
|
|
||||||
BaseView.prototype.show = function (data) {
|
|
||||||
};
|
|
||||||
BaseView.prototype.refreshData = function (data) {
|
|
||||||
this._data = data;
|
|
||||||
};
|
|
||||||
BaseView.prototype.refreshView = function () {
|
|
||||||
};
|
|
||||||
BaseView.prototype.close = function () {
|
|
||||||
};
|
|
||||||
BaseView.prototype.destroy = function () {
|
|
||||||
if (this.parent) {
|
|
||||||
this.parent.removeChild(this);
|
|
||||||
}
|
|
||||||
while (this.numChildren > 0) {
|
|
||||||
this.removeChildAt(0);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
return BaseView;
|
|
||||||
}(egret.DisplayObjectContainer));
|
|
||||||
var BaseFuiView = (function (_super) {
|
|
||||||
__extends(BaseFuiView, _super);
|
|
||||||
function BaseFuiView(name) {
|
|
||||||
var _this = _super.call(this) || this;
|
|
||||||
_this.name = name;
|
|
||||||
return _this;
|
|
||||||
}
|
|
||||||
return BaseFuiView;
|
|
||||||
}(BaseView));
|
|
||||||
var BaseSingle = (function () {
|
|
||||||
function BaseSingle() {
|
|
||||||
}
|
|
||||||
BaseSingle.getInstance = function () {
|
|
||||||
if (this._instance == null) {
|
|
||||||
this._instance = new this();
|
|
||||||
}
|
|
||||||
return this._instance;
|
|
||||||
};
|
|
||||||
BaseSingle.prototype.clearFuiObj = function (obj) {
|
|
||||||
if (obj) {
|
|
||||||
egret.Tween.removeTweens(obj.displayObject);
|
|
||||||
if (obj.displayObject && obj.displayObject.parent) {
|
|
||||||
obj.displayObject.parent.removeChild(obj.displayObject);
|
|
||||||
}
|
|
||||||
obj.dispose();
|
|
||||||
obj = null;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
return BaseSingle;
|
|
||||||
}());
|
|
||||||
var ViewManager = (function (_super) {
|
|
||||||
__extends(ViewManager, _super);
|
|
||||||
function ViewManager() {
|
|
||||||
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
||||||
_this._openDic = [];
|
|
||||||
return _this;
|
|
||||||
}
|
|
||||||
ViewManager.prototype.refreshView = function (viewClass, data) {
|
|
||||||
var view = this.getView(viewClass);
|
|
||||||
if (view) {
|
|
||||||
view.refreshData(data);
|
|
||||||
view.refreshView();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
ViewManager.prototype.openView = function (viewClass, data, complete) {
|
|
||||||
var newView = this.getView(viewClass);
|
|
||||||
if (!newView) {
|
|
||||||
newView = new viewClass();
|
|
||||||
}
|
|
||||||
if (this.existView(viewClass)) {
|
|
||||||
newView.refreshData(data);
|
|
||||||
newView.refreshView();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this._openDic.push(newView);
|
|
||||||
};
|
|
||||||
ViewManager.prototype.getView = function (viewClass) {
|
|
||||||
var result = this._openDic.firstOrDefault(function (a) {
|
|
||||||
return a instanceof viewClass;
|
|
||||||
});
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
ViewManager.prototype.existView = function (viewClass) {
|
|
||||||
return this._openDic.findIndex(function (a) {
|
|
||||||
return a instanceof viewClass;
|
|
||||||
}) != -1;
|
|
||||||
};
|
|
||||||
return ViewManager;
|
|
||||||
}(BaseSingle));
|
|
||||||
var Flags = (function () {
|
var Flags = (function () {
|
||||||
function Flags() {
|
function Flags() {
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
-2452
File diff suppressed because it is too large
Load Diff
@@ -2,6 +2,8 @@ abstract class Component extends egret.DisplayObjectContainer {
|
|||||||
public entity: Entity;
|
public entity: Entity;
|
||||||
private _enabled: boolean = true;
|
private _enabled: boolean = true;
|
||||||
public updateInterval: number = 1;
|
public updateInterval: number = 1;
|
||||||
|
/** 允许用户为实体存入信息 */
|
||||||
|
public userData: any;
|
||||||
|
|
||||||
public get enabled(){
|
public get enabled(){
|
||||||
return this.entity ? this.entity.enabled && this._enabled : this._enabled;
|
return this.entity ? this.entity.enabled && this._enabled : this._enabled;
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
class SpriteAnimation {
|
||||||
|
public readonly sprites: Sprite[];
|
||||||
|
public readonly frameRate: number;
|
||||||
|
|
||||||
|
constructor(sprites: Sprite[], frameRate: number){
|
||||||
|
this.sprites = sprites;
|
||||||
|
this.frameRate = frameRate;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,142 @@
|
|||||||
|
///<reference path="./SpriteRenderer.ts" />
|
||||||
|
class SpriteAnimator extends SpriteRenderer {
|
||||||
|
/** 在动画完成时触发,包括动画名称; */
|
||||||
|
public onAnimationCompletedEvent: Function;
|
||||||
|
/** 动画播放速度 */
|
||||||
|
public speed = 1;
|
||||||
|
/** 动画的当前状态 */
|
||||||
|
public animationState = State.none;
|
||||||
|
/** 当前动画 */
|
||||||
|
public currentAnimation: SpriteAnimation;
|
||||||
|
/** 当前动画的名称 */
|
||||||
|
public currentAnimationName: string;
|
||||||
|
/** 当前动画的精灵数组中当前帧的索引 */
|
||||||
|
public currentFrame: number;
|
||||||
|
/** 检查当前动画是否正在运行 */
|
||||||
|
public get isRunning(): boolean{
|
||||||
|
return this.animationState == State.running;
|
||||||
|
}
|
||||||
|
|
||||||
|
private _animations: Map<string, SpriteAnimation> = new Map<string, SpriteAnimation>();
|
||||||
|
private _elapsedTime: number = 0;
|
||||||
|
private _loopMode: LoopMode;
|
||||||
|
|
||||||
|
constructor(sprite?: Sprite){
|
||||||
|
super();
|
||||||
|
|
||||||
|
if (sprite) this.setSprite(sprite);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加一个SpriteAnimation
|
||||||
|
* @param name
|
||||||
|
* @param animation
|
||||||
|
*/
|
||||||
|
public addAnimation(name: string, animation: SpriteAnimation): SpriteAnimator{
|
||||||
|
if (!this.sprite && animation.sprites.length > 0)
|
||||||
|
this.setSprite(animation.sprites[0]);
|
||||||
|
this._animations[name] = animation;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 以给定的名称放置动画。如果没有指定循环模式,则默认为循环
|
||||||
|
* @param name
|
||||||
|
* @param loopMode
|
||||||
|
*/
|
||||||
|
public play(name: string, loopMode: LoopMode = null){
|
||||||
|
this.currentAnimation = this._animations[name];
|
||||||
|
this.currentAnimationName = name;
|
||||||
|
this.currentFrame = 0;
|
||||||
|
this.animationState = State.running;
|
||||||
|
|
||||||
|
this.sprite = this.currentAnimation.sprites[0];
|
||||||
|
this._elapsedTime = 0;
|
||||||
|
this._loopMode = loopMode ? loopMode : LoopMode.loop;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查动画是否正在播放(即动画是活动的)。它可能仍然处于暂停状态)
|
||||||
|
* @param name
|
||||||
|
*/
|
||||||
|
public isAnimationActive(name: string): boolean{
|
||||||
|
return this.currentAnimation && this.currentAnimationName == name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 暂停动画
|
||||||
|
*/
|
||||||
|
public pause(){
|
||||||
|
this.animationState = State.paused;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 继续动画
|
||||||
|
*/
|
||||||
|
public unPause(){
|
||||||
|
this.animationState = State.running;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 停止当前动画并将其设为null
|
||||||
|
*/
|
||||||
|
public stop(){
|
||||||
|
this.currentAnimation = null;
|
||||||
|
this.currentAnimationName = null;
|
||||||
|
this.currentFrame = 0;
|
||||||
|
this.animationState = State.none;
|
||||||
|
}
|
||||||
|
|
||||||
|
public update(){
|
||||||
|
if (this.animationState != State.running || !this.currentAnimation) return;
|
||||||
|
|
||||||
|
let animation = this.currentAnimation;
|
||||||
|
let secondsPerFrame = 1 / (animation.frameRate * this.speed);
|
||||||
|
let iterationDuration = secondsPerFrame * animation.sprites.length;
|
||||||
|
|
||||||
|
this._elapsedTime += Time.deltaTime;
|
||||||
|
let time = Math.abs(this._elapsedTime);
|
||||||
|
|
||||||
|
if (this._loopMode == LoopMode.once && time > iterationDuration ||
|
||||||
|
this._loopMode == LoopMode.pingPongOnce && time > iterationDuration * 2){
|
||||||
|
this.animationState = State.completed;
|
||||||
|
this._elapsedTime = 0;
|
||||||
|
this.currentFrame = 0;
|
||||||
|
this.sprite = animation.sprites[this.currentFrame];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 弄清楚我们在哪个坐标系上
|
||||||
|
let i = Math.floor(time / secondsPerFrame);
|
||||||
|
let n = animation.sprites.length;
|
||||||
|
if (n > 2 && (this._loopMode == LoopMode.pingPong || this._loopMode == LoopMode.pingPongOnce)){
|
||||||
|
// pingpong
|
||||||
|
let maxIndex = n - 1;
|
||||||
|
this.currentFrame = maxIndex - Math.abs(maxIndex - i % (maxIndex * 2));
|
||||||
|
}else{
|
||||||
|
this.currentFrame = i % n;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.sprite = animation.sprites[this.currentFrame];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
enum LoopMode {
|
||||||
|
/** 在一个循环序列[A][B][C][A][B][C][A][B][C]... */
|
||||||
|
loop,
|
||||||
|
/** [A][B][C]然后暂停,设置时间为0 [A] */
|
||||||
|
once,
|
||||||
|
/** [A][B][C]。当它到达终点时,它会继续播放最后一帧,并且不会停止播放 */
|
||||||
|
clampForever,
|
||||||
|
/** 以一个乒乓循环的方式永远播放这个序列 [A][B][C][B][A][B][C][B]... */
|
||||||
|
pingPong,
|
||||||
|
/** 将顺序向前播放一次,然后返回到开始[A][B][C][B][A],然后暂停并设置时间为0 */
|
||||||
|
pingPongOnce,
|
||||||
|
}
|
||||||
|
|
||||||
|
enum State {
|
||||||
|
none,
|
||||||
|
running,
|
||||||
|
paused,
|
||||||
|
completed,
|
||||||
|
}
|
||||||
@@ -15,6 +15,14 @@ class SpriteRenderer extends RenderableComponent {
|
|||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
/** 应该由这个精灵显示的精灵。当设置时,精灵的原点也被设置为匹配精灵.origin。 */
|
||||||
|
public get sprite(): Sprite{
|
||||||
|
return this._sprite;
|
||||||
|
}
|
||||||
|
/** 应该由这个精灵显示的精灵。当设置时,精灵的原点也被设置为匹配精灵.origin。 */
|
||||||
|
public set sprite(value: Sprite){
|
||||||
|
this.setSprite(value);
|
||||||
|
}
|
||||||
|
|
||||||
public setSprite(sprite: Sprite): SpriteRenderer{
|
public setSprite(sprite: Sprite): SpriteRenderer{
|
||||||
this.removeChildren();
|
this.removeChildren();
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
///<reference path="./BaseView.ts" />
|
|
||||||
/** 用于承载fui界面 */
|
|
||||||
class BaseFuiView extends BaseView {
|
|
||||||
/** 界面名称 */
|
|
||||||
protected _name: string;
|
|
||||||
|
|
||||||
constructor(name: string){
|
|
||||||
super();
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
/** 用于表示单例类 */
|
|
||||||
class BaseSingle {
|
|
||||||
private static _instance: any;
|
|
||||||
|
|
||||||
public static getInstance<T>(): T {
|
|
||||||
if (this._instance == null) {
|
|
||||||
this._instance = new this();
|
|
||||||
}
|
|
||||||
return this._instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**清除fgui元素 */
|
|
||||||
protected clearFuiObj(obj: fairygui.GObject): boolean {
|
|
||||||
if (obj) {
|
|
||||||
egret.Tween.removeTweens(obj.displayObject);
|
|
||||||
if (obj.displayObject && obj.displayObject.parent) {
|
|
||||||
obj.displayObject.parent.removeChild(obj.displayObject);
|
|
||||||
}
|
|
||||||
obj.dispose();
|
|
||||||
obj = null;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
/** 所有视图的基类 */
|
|
||||||
class BaseView extends egret.DisplayObjectContainer {
|
|
||||||
/** 界面数据 */
|
|
||||||
protected _data: any;
|
|
||||||
/** 在打开界面前触发 */
|
|
||||||
protected init(){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 窗口打开时触发 */
|
|
||||||
public show(data?: any) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 刷新界面数据 由mvc控制 */
|
|
||||||
public refreshData(data?: any){
|
|
||||||
this._data = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 刷新界面逻辑 */
|
|
||||||
public refreshView(){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 关闭窗口 */
|
|
||||||
public close() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 销毁窗口 */
|
|
||||||
public destroy(){
|
|
||||||
if (this.parent){
|
|
||||||
this.parent.removeChild(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 循环删除此界面下所有节点 */
|
|
||||||
while (this.numChildren > 0) {
|
|
||||||
this.removeChildAt(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
class ViewManager extends BaseSingle {
|
|
||||||
private _openDic: BaseFuiView[] = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 刷新界面
|
|
||||||
* @param viewClass 界面类型
|
|
||||||
* @param data 界面数据
|
|
||||||
*/
|
|
||||||
public refreshView(viewClass: any, data?: any){
|
|
||||||
let view = this.getView<BaseFuiView>(viewClass);
|
|
||||||
|
|
||||||
if (view){
|
|
||||||
/** 压入数据 */
|
|
||||||
view.refreshData(data);
|
|
||||||
/** 执行刷新逻辑 */
|
|
||||||
view.refreshView();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 打开界面
|
|
||||||
* @param viewClass 界面类型
|
|
||||||
* @param data 界面数据
|
|
||||||
* @param complete 界面加载完成回调
|
|
||||||
*/
|
|
||||||
public openView(viewClass: any, data?: any, complete?: Function){
|
|
||||||
let newView = this.getView<BaseFuiView>(viewClass);
|
|
||||||
if (!newView){
|
|
||||||
newView = new viewClass();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 如果界面已打开 则执行刷新界面 */
|
|
||||||
if (this.existView(viewClass)){
|
|
||||||
newView.refreshData(data);
|
|
||||||
newView.refreshView();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this._openDic.push(newView);
|
|
||||||
// TODO: 加载资源
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取界面 可能为null
|
|
||||||
* @param viewClass 界面类型
|
|
||||||
*/
|
|
||||||
public getView<T>(viewClass: any): T {
|
|
||||||
let result: any = this._openDic.firstOrDefault(a => {
|
|
||||||
return a instanceof viewClass;
|
|
||||||
});
|
|
||||||
|
|
||||||
return result as T;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 界面是否存在
|
|
||||||
* @param viewClass 界面类型
|
|
||||||
*/
|
|
||||||
public existView(viewClass: any): boolean {
|
|
||||||
return this._openDic.findIndex(a => {
|
|
||||||
return a instanceof viewClass;
|
|
||||||
}) != -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user