新增allTweensWithTargetEntity与clearAllCoroutines方法
This commit is contained in:
17
source/bin/framework.d.ts
vendored
17
source/bin/framework.d.ts
vendored
@@ -3866,6 +3866,7 @@ declare module es {
|
||||
* 它可以做任何需要每帧执行的事情。
|
||||
*/
|
||||
abstract class AbstractTweenable implements ITweenable {
|
||||
readonly discriminator: string;
|
||||
protected _isPaused: boolean;
|
||||
/**
|
||||
* abstractTweenable在完成后往往会被保留下来。
|
||||
@@ -3931,6 +3932,7 @@ declare module es {
|
||||
complete = 2
|
||||
}
|
||||
abstract class Tween<T> implements ITweenable, ITween<T> {
|
||||
readonly discriminator: "ITweenControl";
|
||||
protected _target: ITweenTarget<T>;
|
||||
protected _isFromValueOverridden: boolean;
|
||||
protected _fromValue: T;
|
||||
@@ -4151,6 +4153,7 @@ declare module es {
|
||||
* 当前所有活跃用户的内部列表
|
||||
*/
|
||||
private _activeTweens;
|
||||
static readonly activeTweens: ITweenable[];
|
||||
private _tempTweens;
|
||||
/**
|
||||
* 标志表示tween更新循环正在运行
|
||||
@@ -4195,6 +4198,12 @@ declare module es {
|
||||
* @param target
|
||||
*/
|
||||
static allTweenWithTarget(target: any): ITweenable[];
|
||||
/**
|
||||
* 返回以特定实体为目标的所有tween
|
||||
* Tween返回为ITweenControl
|
||||
* @param target
|
||||
*/
|
||||
static allTweensWithTargetEntity(target: Entity): any[];
|
||||
/**
|
||||
* 停止所有具有TweenManager知道的特定目标的tweens
|
||||
* @param target
|
||||
@@ -4374,6 +4383,7 @@ declare module es {
|
||||
* 更多具体的Tween播放控制在这里
|
||||
*/
|
||||
interface ITweenControl extends ITweenable {
|
||||
readonly discriminator: "ITweenControl";
|
||||
/**
|
||||
* 当使用匿名方法时,您可以在任何回调(如完成处理程序)中使用该属性来避免分配
|
||||
*/
|
||||
@@ -4413,6 +4423,7 @@ declare module es {
|
||||
}
|
||||
declare module es {
|
||||
interface ITweenable {
|
||||
readonly discriminator: string;
|
||||
/**
|
||||
* 就像内部的Update一样,每一帧都被TweenManager调用
|
||||
*/
|
||||
@@ -5044,7 +5055,7 @@ declare module es {
|
||||
* CoroutineManager用于隐藏Coroutine所需数据的内部类
|
||||
*/
|
||||
class CoroutineImpl implements ICoroutine, IPoolable {
|
||||
enumerator: any;
|
||||
enumerator: Generator;
|
||||
/**
|
||||
* 每当产生一个延迟,它就会被添加到跟踪延迟的waitTimer中
|
||||
*/
|
||||
@@ -5065,6 +5076,10 @@ declare module es {
|
||||
_isInUpdate: boolean;
|
||||
_unblockedCoroutines: CoroutineImpl[];
|
||||
_shouldRunNextFrame: CoroutineImpl[];
|
||||
/**
|
||||
* 立即停止并清除所有协程
|
||||
*/
|
||||
clearAllCoroutines(): void;
|
||||
/**
|
||||
* 将IEnumerator添加到CoroutineManager中
|
||||
* Coroutine在每一帧调用Update之前被执行
|
||||
|
||||
@@ -9838,6 +9838,7 @@ var es;
|
||||
*/
|
||||
var AbstractTweenable = /** @class */ (function () {
|
||||
function AbstractTweenable() {
|
||||
this.discriminator = "ITweenable";
|
||||
}
|
||||
AbstractTweenable.prototype.recycleSelf = function () {
|
||||
};
|
||||
@@ -10689,6 +10690,13 @@ var es;
|
||||
TweenManager._instance = _this;
|
||||
return _this;
|
||||
}
|
||||
Object.defineProperty(TweenManager, "activeTweens", {
|
||||
get: function () {
|
||||
return this._instance._activeTweens;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
TweenManager.prototype.update = function () {
|
||||
this._isUpdating = true;
|
||||
// 反向循环,这样我们就可以把完成的weens删除了
|
||||
@@ -10774,6 +10782,26 @@ var es;
|
||||
}
|
||||
return foundTweens;
|
||||
};
|
||||
/**
|
||||
* 返回以特定实体为目标的所有tween
|
||||
* Tween返回为ITweenControl
|
||||
* @param target
|
||||
*/
|
||||
TweenManager.allTweensWithTargetEntity = function (target) {
|
||||
var foundTweens = [];
|
||||
for (var i = 0; i < this._instance._activeTweens.length; i++) {
|
||||
if (this._instance._activeTweens[i].discriminator == "ITweenControl") {
|
||||
var tweenControl = this._instance._activeTweens[i];
|
||||
var obj = tweenControl.getTargetObject();
|
||||
if (obj instanceof es.Entity && obj == target ||
|
||||
obj instanceof es.Component && obj.entity == target ||
|
||||
obj instanceof es.Transform && obj.entity == target) {
|
||||
foundTweens.push(this._instance._activeTweens[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return foundTweens;
|
||||
};
|
||||
/**
|
||||
* 停止所有具有TweenManager知道的特定目标的tweens
|
||||
* @param target
|
||||
@@ -12998,6 +13026,19 @@ var es;
|
||||
_this._shouldRunNextFrame = [];
|
||||
return _this;
|
||||
}
|
||||
/**
|
||||
* 立即停止并清除所有协程
|
||||
*/
|
||||
CoroutineManager.prototype.clearAllCoroutines = function () {
|
||||
for (var i = 0; i < this._unblockedCoroutines.length; i++) {
|
||||
es.Pool.free(CoroutineImpl, this._unblockedCoroutines[i]);
|
||||
}
|
||||
for (var i = 0; i < this._shouldRunNextFrame.length; i++) {
|
||||
es.Pool.free(CoroutineImpl, this._shouldRunNextFrame[i]);
|
||||
}
|
||||
this._unblockedCoroutines.length = 0;
|
||||
this._shouldRunNextFrame.length = 0;
|
||||
};
|
||||
/**
|
||||
* 将IEnumerator添加到CoroutineManager中
|
||||
* Coroutine在每一帧调用Update之前被执行
|
||||
@@ -13079,6 +13120,10 @@ var es;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (typeof chain.value == 'function') {
|
||||
coroutine.waitForCoroutine = this.startCoroutine(chain.value);
|
||||
return true;
|
||||
}
|
||||
if (chain.value instanceof CoroutineImpl) {
|
||||
coroutine.waitForCoroutine = chain.value;
|
||||
return true;
|
||||
|
||||
2
source/bin/framework.min.js
vendored
2
source/bin/framework.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -6,6 +6,7 @@ module es {
|
||||
* 它可以做任何需要每帧执行的事情。
|
||||
*/
|
||||
export abstract class AbstractTweenable implements ITweenable {
|
||||
readonly discriminator = "ITweenable";
|
||||
protected _isPaused: boolean;
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,6 +3,7 @@ module es {
|
||||
* 更多具体的Tween播放控制在这里
|
||||
*/
|
||||
export interface ITweenControl extends ITweenable {
|
||||
readonly discriminator: "ITweenControl";
|
||||
/**
|
||||
* 当使用匿名方法时,您可以在任何回调(如完成处理程序)中使用该属性来避免分配
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
module es {
|
||||
export interface ITweenable {
|
||||
readonly discriminator: string;
|
||||
/**
|
||||
* 就像内部的Update一样,每一帧都被TweenManager调用
|
||||
*/
|
||||
|
||||
@@ -12,6 +12,7 @@ module es {
|
||||
}
|
||||
|
||||
export abstract class Tween<T> implements ITweenable, ITween<T> {
|
||||
readonly discriminator: "ITweenControl";
|
||||
protected _target: ITweenTarget<T>;
|
||||
protected _isFromValueOverridden: boolean;
|
||||
protected _fromValue: T;
|
||||
|
||||
@@ -23,6 +23,10 @@ module es {
|
||||
* 当前所有活跃用户的内部列表
|
||||
*/
|
||||
private _activeTweens: ITweenable[] = [];
|
||||
public static get activeTweens(): ITweenable[] {
|
||||
return this._instance._activeTweens;
|
||||
}
|
||||
|
||||
private _tempTweens: ITweenable[] = [];
|
||||
/**
|
||||
* 标志表示tween更新循环正在运行
|
||||
@@ -134,6 +138,29 @@ module es {
|
||||
return foundTweens;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回以特定实体为目标的所有tween
|
||||
* Tween返回为ITweenControl
|
||||
* @param target
|
||||
*/
|
||||
public static allTweensWithTargetEntity(target: Entity) {
|
||||
let foundTweens = [];
|
||||
|
||||
for (let i = 0; i < this._instance._activeTweens.length; i ++) {
|
||||
if (this._instance._activeTweens[i].discriminator == "ITweenControl") {
|
||||
let tweenControl = this._instance._activeTweens[i] as ITweenControl;
|
||||
let obj = tweenControl.getTargetObject();
|
||||
if (obj instanceof Entity && obj == target ||
|
||||
obj instanceof Component && obj.entity == target ||
|
||||
obj instanceof Transform && obj.entity == target) {
|
||||
foundTweens.push(this._instance._activeTweens[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return foundTweens;
|
||||
}
|
||||
|
||||
/**
|
||||
* 停止所有具有TweenManager知道的特定目标的tweens
|
||||
* @param target
|
||||
|
||||
@@ -3,7 +3,7 @@ module es {
|
||||
* CoroutineManager用于隐藏Coroutine所需数据的内部类
|
||||
*/
|
||||
export class CoroutineImpl implements ICoroutine, IPoolable {
|
||||
public enumerator: any;
|
||||
public enumerator: Generator;
|
||||
|
||||
/**
|
||||
* 每当产生一个延迟,它就会被添加到跟踪延迟的waitTimer中
|
||||
@@ -46,6 +46,22 @@ module es {
|
||||
public _unblockedCoroutines: CoroutineImpl[] = [];
|
||||
public _shouldRunNextFrame: CoroutineImpl[] = [];
|
||||
|
||||
/**
|
||||
* 立即停止并清除所有协程
|
||||
*/
|
||||
public clearAllCoroutines() {
|
||||
for (let i = 0; i < this._unblockedCoroutines.length; i ++) {
|
||||
Pool.free(CoroutineImpl, this._unblockedCoroutines[i]);
|
||||
}
|
||||
|
||||
for (let i = 0; i < this._shouldRunNextFrame.length; i ++) {
|
||||
Pool.free(CoroutineImpl, this._shouldRunNextFrame[i]);
|
||||
}
|
||||
|
||||
this._unblockedCoroutines.length = 0;
|
||||
this._shouldRunNextFrame.length = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将IEnumerator添加到CoroutineManager中
|
||||
* Coroutine在每一帧调用Update之前被执行
|
||||
@@ -144,6 +160,11 @@ module es {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (typeof chain.value == 'function') {
|
||||
coroutine.waitForCoroutine = this.startCoroutine(chain.value);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (chain.value instanceof CoroutineImpl) {
|
||||
coroutine.waitForCoroutine = chain.value;
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user