Engine.TweenGroup = class
{
constructor()
{
this.tweenPool = new Engine.ObjectPool(Engine.SimpleTween);
this.activeTweens = [];//new List<SimpleTween>();
this.timeScale = 1.0;
}
get timeScale()
{
return this._timeScale;
}
set timeScale(value)
{
this._timeScale = value;
for(var tween of this.activeTweens)
{
tween.timeScale = this._timeScale;
}
}
clear()
{
for(var tween of this.activeTweens)
{
tween.onStop = null;
tween.stop();
tween.onFinish = null;
tween.onUpdate = null;
this.tweenPool.returnObject(tween);
}
this.activeTweens.length = 0;
}
addNew(onUpdate /*SimpleTweenUpdate*/, onFinish /*SimpleTweenFinish*/, tweenFunc /*SimpleTween.TweenFunction*/, start /*float*/, end /*float*/, time /*float*/, toInt /*bool*/)
{
var tween = this.tweenPool.getNextObject();
this.activeTweens.push(tween);
tween.init(onUpdate, tweenFunc, start, end, time, toInt);
tween.timeScale = this.timeScale;
tween.onFinish = () =>
{
tween.onFinish = null;
tween.onUpdate = null;
this.activeTweens.remove(tween);
this.tweenPool.returnObject(tween);
if (onFinish != null) onFinish();
};
tween.onStop = () =>
{
this.activeTweens.remove(tween);
this.tweenPool.returnObject(tween);
}
return tween;
}
}