内置tween管理器
This commit is contained in:
@@ -491,6 +491,66 @@ module es {
|
||||
}
|
||||
}
|
||||
|
||||
public tweenPositionTo(to: Vector2, duration: number = 0.3): ITween<Vector2> {
|
||||
const tween = Pool.obtain(TransformVector2Tween);
|
||||
tween.setTargetAndType(this.transform, TransformTargetType.position);
|
||||
tween.initialize(tween, to, duration);
|
||||
|
||||
return tween;
|
||||
}
|
||||
|
||||
public tweenLocalPositionTo(to: Vector2, duration = 0.3): ITween<Vector2> {
|
||||
const tween = Pool.obtain(TransformVector2Tween);
|
||||
tween.setTargetAndType(this.transform, TransformTargetType.localPosition);
|
||||
tween.initialize(tween, to, duration);
|
||||
|
||||
return tween;
|
||||
}
|
||||
|
||||
public tweenScaleTo(to: Vector2, duration?: number);
|
||||
public tweenScaleTo(to: number, duration?: number);
|
||||
public tweenScaleTo(to: Vector2 | number, duration: number = 0.3) {
|
||||
if (typeof (to) == 'number') {
|
||||
return this.tweenScaleTo(new Vector2(to, to), duration);
|
||||
}
|
||||
|
||||
const tween = Pool.obtain(TransformVector2Tween);
|
||||
tween.setTargetAndType(this.transform, TransformTargetType.scale);
|
||||
tween.initialize(tween, to, duration);
|
||||
|
||||
return tween;
|
||||
}
|
||||
|
||||
public tweenLocalScaleTo(to: Vector2, duration?);
|
||||
public tweenLocalScaleTo(to: number, duration?);
|
||||
public tweenLocalScaleTo(to: Vector2 | number, duration = 0.3) {
|
||||
if (typeof (to) == 'number') {
|
||||
return this.tweenLocalScaleTo(new Vector2(to, to), duration);
|
||||
}
|
||||
|
||||
const tween = Pool.obtain(TransformVector2Tween);
|
||||
tween.setTargetAndType(this.transform, TransformTargetType.localScale);
|
||||
tween.initialize(tween, to, duration);
|
||||
|
||||
return tween;
|
||||
}
|
||||
|
||||
public tweenRotationDegreesTo(to: number, duration = 0.3) {
|
||||
const tween = Pool.obtain(TransformVector2Tween);
|
||||
tween.setTargetAndType(this.transform, TransformTargetType.rotationDegrees);
|
||||
tween.initialize(tween, new Vector2(to, to), duration);
|
||||
|
||||
return tween;
|
||||
}
|
||||
|
||||
public tweenLocalRotationDegreesTo(to: number, duration = 0.3) {
|
||||
const tween = Pool.obtain(TransformVector2Tween);
|
||||
tween.setTargetAndType(this.transform, TransformTargetType.localRotationDegrees);
|
||||
tween.initialize(tween, new Vector2(to, to), duration);
|
||||
|
||||
return tween;
|
||||
}
|
||||
|
||||
public compareTo(other: Entity): number {
|
||||
let compare = this._updateOrder - other._updateOrder;
|
||||
if (compare == 0)
|
||||
|
||||
Reference in New Issue
Block a user