TweenTransform
Tween subclass for transform animations (position, rotation, scale).
| Type | Name | Interface Description |
|---|---|---|
| Variables | endNumber: number | • Function: End number (2D Rotation). |
| Variables | endVector2: Vector2f | • Function: End Vector2 (2D Position/Scale). |
| Variables | endVector3: Vector3f | • Function: End Vector3 (3D, all targets). Used in FromTo and To modes. |
| Variables | offsetNumber: number | • Function: Offset number (2D Rotation). Only used when motionType=Offset. |
| Variables | offsetVector2: Vector2f | • Function: Offset Vector2 (2D Position/Scale). Only used when motionType=Offset. |
| Variables | offsetVector3: Vector3f | • Function: Offset Vector3 (3D). Only used when motionType=Offset. |
| Variables | startNumber: number | • Function: Start number (2D Rotation). Only used when motionType=FromTo. |
| Variables | startVector2: Vector2f | • Function: Start Vector2 (2D Position/Scale). Only used when motionType=FromTo. |
| Variables | startVector3: Vector3f | • Function: Start Vector3 (3D, all targets). Only used when motionType=FromTo. |
| Variables | targetType: TweenTargetType | |
| Functions | constructor() | |
| Functions | pause(): void | • Function: Pause tween animation. |
| Functions | resume(): void | • Function: Resume tween animation. |
| Functions | start(): void | • Function: Start tween animation from initial state. |
| Functions | stop(): void | • Function: Stop the tween animation and keep the current state. |
Examples
constructor()
let obj = new APJS.TweenTransform();
Use Case
Scale bounce animation on tap — object pops up to 1.5x then settles back using Tween component with PingPongOnce
@component()
export class TweenScaleBounce extends APJS.BasicScriptComponent {
private tween!: APJS.Tween;
private touchCallback!: (event: APJS.IEvent) => void;
onStart(): void {
this.tween = this.getSceneObject().getComponent("Tween") as APJS.Tween;
this.touchCallback = (event: APJS.IEvent) => {
const touch = event.args[0] as APJS.TouchData;
if (touch.phase === APJS.TouchPhase.Began) {
this.playBounce();
}
};
APJS.EventManager.getGlobalEmitter().on(APJS.EventType.Touch, this.touchCallback, this);
}
private playBounce(): void {
if (!this.tween) return;
// Default tweenType is TransformPath — use TweenTransformPath API
const anim = this.tween.tweenAnimation as APJS.TweenTransformPath;
anim.targetType = APJS.TweenTargetType.Scale;
anim.pointsPathVector3 = [
new APJS.Vector3f(1, 1, 1),
new APJS.Vector3f(1.5, 1.5, 1.5),
];
anim.durations = [0.4];
anim.fixedDuration = true;
anim.pathType = APJS.TweenPathType.Straight;
anim.easingFunction = APJS.TweenEasingFunction.Back;
anim.easingType = APJS.TweenEasingType.Out;
anim.playMode = APJS.TweenPlayMode.PingPongOnce;
anim.start();
}
onDestroy(): void {
APJS.EventManager.getGlobalEmitter().off(APJS.EventType.Touch, this.touchCallback, this);
}
}