Skip to main content

Class: Tween<T>

Tweening.Tween

A Tween represents a series of actions that can be applied to a target object to create animations or sequences of events.

Type parameters

NameTypeDescription
TanyThe type of the target object.

Constructors

constructor

new Tween<T>(target)

Type parameters

NameType
Tany

Parameters

NameTypeDescription
targetTThe object to apply the tween to.

Defined in

src/tweening/Tween.ts:23

Properties

id

id: string

Unique identifier. If specified, the old tween with the same id will be stopped.

Defined in

src/tweening/Tween.ts:18


tags

tags: string[] = []

Tags used for filtering and management.

Defined in

src/tweening/Tween.ts:16


target

target: T

The object to apply the tween to.

Defined in

src/tweening/Tween.ts:14

Methods

by

by(time, action, config?): Tween<T>

Define a relative motion from the current state.

Parameters

NameTypeDescription
timenumberThe duration of the motion in milliseconds.
actionMotion<T>The motion configuration.
config?MotionConfig<T>Additional motion configuration options.

Returns

Tween<T>

The updated Tween instance.

Defined in

src/tweening/Tween.ts:76


call

call(callback): Tween<T>

Add a callback action to the Tween.

Parameters

NameTypeDescription
callback() => voidThe callback function to execute.

Returns

Tween<T>

The updated Tween instance.

Defined in

src/tweening/Tween.ts:96


chain

chain(tween): Tween<T>

Chain actions from another Tween to this Tween.

Parameters

NameTypeDescription
tweenTween<T>The Tween containing actions to chain.

Returns

Tween<T>

The updated Tween instance.

Defined in

src/tweening/Tween.ts:202


clone

clone(): Tween<T>

Clone the Tween instance.

Returns

Tween<T>

A new Tween instance with the same configuration.

Defined in

src/tweening/Tween.ts:212


delay

delay(time): Tween<T>

Add a delay before executing the next action.

Parameters

NameTypeDescription
timenumberThe duration of the delay in milliseconds.

Returns

Tween<T>

The updated Tween instance.

Defined in

src/tweening/Tween.ts:106


parallel

parallel(...tweens): Tween<T>

Run multiple Tweens in parallel.

Parameters

NameTypeDescription
...tweensTween<T>[]The Tweens to run in parallel.

Returns

Tween<T>

The updated Tween instance.

Defined in

src/tweening/Tween.ts:178


repeat

repeat(times?): Tween<T>

Repeat the last action for a specific number of times.

Parameters

NameTypeDefault valueDescription
timesnumber1The number of times to repeat the action.

Returns

Tween<T>

The updated Tween instance.

Defined in

src/tweening/Tween.ts:116


repeatForever

repeatForever(): Tween<T>

Repeat the last action indefinitely.

Returns

Tween<T>

The updated Tween instance.

Defined in

src/tweening/Tween.ts:133


sequence

sequence(...tweens): Tween<T>

Run multiple Tweens in sequence.

Parameters

NameTypeDescription
...tweensTween<T>[]The Tweens to run in sequence.

Returns

Tween<T>

The updated Tween instance.

Defined in

src/tweening/Tween.ts:189


set

set(action): Tween<T>

Define a movement from the current state to a new state instantaneously.

Parameters

NameTypeDescription
actionSetMotion<T>The motion configuration.

Returns

Tween<T>

The updated Tween instance.

Defined in

src/tweening/Tween.ts:86


setId

setId(id): Tween<T>

Set a unique identifier for the Tween. If specified, stops the old tween with the same id.

Parameters

NameTypeDescription
idstringThe identifier to assign to the Tween.

Returns

Tween<T>

The updated Tween instance.

Defined in

src/tweening/Tween.ts:32


setTags

setTags(...tags): Tween<T>

Set tags for the Tween, which can be used for filtering and management.

Parameters

NameTypeDescription
...tagsstring[]Tags to associate with the Tween.

Returns

Tween<T>

The updated Tween instance.

Defined in

src/tweening/Tween.ts:42


setTarget

setTarget(target): Tween<T>

Set the target object for the Tween.

Parameters

NameTypeDescription
targetTThe object to apply the tween to.

Returns

Tween<T>

The updated Tween instance.

Defined in

src/tweening/Tween.ts:52


start

start(): RunningTween<T>

Start the Tween and create a RunningTween instance.

Returns

RunningTween<T>

A RunningTween instance that controls the execution of the Tween.

Defined in

src/tweening/Tween.ts:224


then

then(tween): Tween<T>

Chain another Tween to execute after this Tween.

Parameters

NameTypeDescription
tweenTween<T>The Tween to chain.

Returns

Tween<T>

The updated Tween instance.

Defined in

src/tweening/Tween.ts:167


to

to(time, action, config?): Tween<T>

Define a motion from the current state to a new state over a specified time.

Parameters

NameTypeDescription
timenumberThe duration of the motion in milliseconds.
actionMotion<T>The motion configuration.
config?MotionConfig<T>Additional motion configuration options.

Returns

Tween<T>

The updated Tween instance.

Defined in

src/tweening/Tween.ts:64


yoyo

yoyo(times?): Tween<T>

Apply a yoyo effect to the last action, making it reverse its motion, for a specific number of times.

Parameters

NameTypeDefault valueDescription
timesnumber1The number of times to yoyo the last action.

Returns

Tween<T>

The updated Tween instance.

Defined in

src/tweening/Tween.ts:142


yoyoForever

yoyoForever(): Tween<T>

Apply a yoyo effect to the last action, making it reverse its motion, indefinitely.

Returns

Tween<T>

The updated Tween instance.

Defined in

src/tweening/Tween.ts:158