TweenSystem. Tween

A numeric tween: drives a callback with a value interpolated between start and end over duration seconds. Pauses with the game by default.

Constructor

new Tween(callback, startopt, endopt, durationopt, optionsopt)

Create a new tween. The callback fires immediately with start so the target snaps to the start value on the same frame the tween is created.

start and end may be numbers, Vector2 instances, Color instances, or any object exposing a lerp(other, percent) => sameType method. The callback receives the interpolated value (a number, or a fresh instance for lerp-able types). Both endpoints must be the same type.

Parameters:
NameTypeAttributesDefaultDescription
callback
startnumber | Vector2 | Color<optional>
0

Starting value

endnumber | Vector2 | Color<optional>
1

Ending value

durationnumber<optional>
1

Duration in seconds

optionsObject<optional>
Properties
NameTypeAttributesDefaultDescription
easefunction<optional>

Easing function (defaults to LINEAR)

useRealTimeboolean<optional>
false

Advance even when the game is paused (matches Timer's useRealTime)

pausedboolean<optional>
false

Start in paused state

Example
// Animate a fade-out over 2 seconds with an ease-out sine curve.
 new Tween((v) => obj.alpha = v, 1, 0, 2, { ease: Ease.OUT(Ease.SINE) });

TweenSystem. Tween

A numeric tween: drives a callback with a value interpolated between start and end over duration seconds. Pauses with the game by default.

Constructor

new Tween(callback, startopt, endopt, durationopt, optionsopt)

Create a new tween. The callback fires immediately with start so the target snaps to the start value on the same frame the tween is created.

start and end may be numbers, Vector2 instances, Color instances, or any object exposing a lerp(other, percent) => sameType method. The callback receives the interpolated value (a number, or a fresh instance for lerp-able types). Both endpoints must be the same type.

Parameters:
NameTypeAttributesDefaultDescription
callback
startnumber | Vector2 | Color<optional>
0

Starting value

endnumber | Vector2 | Color<optional>
1

Ending value

durationnumber<optional>
1

Duration in seconds

optionsObject<optional>
Properties
NameTypeAttributesDefaultDescription
easefunction<optional>

Easing function (defaults to LINEAR)

useRealTimeboolean<optional>
false

Advance even when the game is paused (matches Timer's useRealTime)

pausedboolean<optional>
false

Start in paused state

Example
// Animate a fade-out over 2 seconds with an ease-out sine curve.
 new Tween((v) => obj.alpha = v, 1, 0, 2, { ease: Ease.OUT(Ease.SINE) });