Namespace: Tweens

Phaser.Types. Tweens

Type Definitions


Event

A Tween Event.

Type:
  • string
Since: 3.19.0
Source: src/tweens/typedefs/Event.js (Line 1)

GetActiveCallback(target, key, value, targetIndex, totalTargets, tween)

Parameters:
Name Type Description
target any

The tween target.

key string

The target property.

value number

The current value of the target property.

targetIndex number

The index of the target within the Tween.

totalTargets number

The total number of targets in this Tween.

tween Phaser.Tweens.Tween

The Tween that invoked this callback.

Since: 3.19.0
Source: src/tweens/typedefs/GetActiveCallback.js (Line 1)
Returns:
  • The new value.
Type
number

GetEndCallback(target, key, value, targetIndex, totalTargets, tween)

Parameters:
Name Type Description
target any

The tween target.

key string

The target property.

value number

The current value of the target property.

targetIndex number

The index of the target within the Tween.

totalTargets number

The total number of targets in this Tween.

tween Phaser.Tweens.Tween

The Tween that invoked this callback.

Since: 3.18.0
Source: src/tweens/typedefs/GetEndCallback.js (Line 1)
Returns:
  • The new value.
Type
number

GetStartCallback(target, key, value, targetIndex, totalTargets, tween)

Parameters:
Name Type Description
target any

The tween target.

key string

The target property.

value number

The current value of the target property.

targetIndex number

The index of the target within the Tween.

totalTargets number

The total number of targets in this Tween.

tween Phaser.Tweens.Tween

The Tween that invoked this callback.

Since: 3.18.0
Source: src/tweens/typedefs/GetStartCallback.js (Line 1)
Returns:
  • The new value.
Type
number

NumberTweenBuilderConfig

Type:
  • object
Properties:
Name Type Argument Default Description
from number <optional>
0

The start number.

to number <optional>
1

The end number.

delay number <optional>
0

The number of milliseconds to delay before the tween will start.

duration number <optional>
1000

The duration of the tween in milliseconds.

ease string | function <optional>
'Power0'

The easing equation to use for the tween.

easeParams array <optional>

Optional easing parameters.

hold number <optional>
0

The number of milliseconds to hold the tween for before yoyo'ing.

repeat number <optional>
0

The number of times to repeat the tween.

repeatDelay number <optional>
0

The number of milliseconds to pause before a tween will repeat.

yoyo boolean <optional>
false

Should the tween complete, then reverse the values incrementally to get back to the starting tween values? The reverse tweening will also take duration milliseconds to complete.

offset string | number | function | object | array <optional>
null

Used when the Tween is part of a Timeline.

completeDelay string | number | function | object | array <optional>
0

The time the tween will wait before the onComplete event is dispatched once it has completed, in ms.

loop string | number | function | object | array <optional>
0

The number of times the tween will repeat. (A value of 1 means the tween will play twice, as it repeated once.) The first loop starts after every property tween has completed once.

loopDelay string | number | function | object | array <optional>
0

The time the tween will pause before starting either a yoyo or returning to the start for a repeat.

paused boolean <optional>
false

Does the tween start in a paused state (true) or playing (false)?

useFrames boolean <optional>
false

Use frames or milliseconds?

callbackScope any <optional>

Scope (this) for the callbacks. The default scope is the tween.

onComplete Phaser.Types.Tweens.TweenOnCompleteCallback <optional>

A function to call when the tween completes.

onCompleteParams array <optional>

Additional parameters to pass to onComplete.

onCompleteScope any <optional>

Scope (this) for onComplete.

onLoop Phaser.Types.Tweens.TweenOnLoopCallback <optional>

A function to call each time the tween loops.

onLoopParams array <optional>

Additional parameters to pass to onLoop.

onLoopScope any <optional>

Scope (this) for onLoop.

onRepeat Phaser.Types.Tweens.TweenOnRepeatCallback <optional>

A function to call each time the tween repeats. Called once per property per target.

onRepeatParams array <optional>

Additional parameters to pass to onRepeat.

onRepeatScope any <optional>

Scope (this) for onRepeat.

onStart Phaser.Types.Tweens.TweenOnStartCallback <optional>

A function to call when the tween starts.

onStartParams array <optional>

Additional parameters to pass to onStart.

onStartScope any <optional>

Scope (this) for onStart.

onStop Phaser.Types.Tweens.TweenOnStopCallback <optional>

A function to call when the tween is stopped.

onStopParams array <optional>

Additional parameters to pass to onStop.

onStopScope any <optional>

Scope (this) for onStop.

onUpdate Phaser.Types.Tweens.TweenOnUpdateCallback <optional>

A function to call each time the tween steps. Called once per property per target.

onUpdateParams array <optional>

Additional parameters to pass to onUpdate.

onUpdateScope any <optional>

Scope (this) for onUpdate.

onYoyo Phaser.Types.Tweens.TweenOnYoyoCallback <optional>

A function to call each time the tween yoyos. Called once per property per target.

onYoyoParams array <optional>

Additional parameters to pass to onYoyo.

onYoyoScope any <optional>

Scope (this) for onYoyo.

Since: 3.18.0
Source: src/tweens/typedefs/NumberTweenBuilderConfig.js (Line 1)

StaggerConfig

Type:
  • object
Properties:
Name Type Argument Default Description
start number <optional>
0

The value to start the stagger from. Can be used as a way to offset the stagger while still using a range for the value.

ease string | function <optional>
'Linear'

An ease to apply across the staggered values. Can either be a string, such as 'sine.inout', or a function.

from string | number <optional>
0

The index to start the stagger from. Can be the strings first, last or center, or an integer representing the stagger position.

grid Array.<number> <optional>

Set the stagger to run across a grid by providing an array where element 0 is the width of the grid and element 1 is the height. Combine with the 'from' property to control direction.

Since: 3.19.0
Source: src/tweens/typedefs/StaggerConfig.js (Line 1)
Example
{
  grid: [ 20, 8 ],
  from: 'center',
  ease: 'Power0',
  start: 100
};

TimelineBuilderConfig

Type:
  • object
Properties:
Name Type Argument Default Description
tweens Array.<Phaser.Types.Tweens.TweenBuilderConfig> | Array.<object> | function <optional>

An array of tween configuration objects to create and add into the new Timeline. If this doesn't exist or is empty, the Timeline will start off paused and none of the other configuration settings will be read. If it's a function, it will be called and its return value will be used as the array.

targets any <optional>

An array (or function which returns one) of default targets to which to apply the Timeline. Each individual Tween configuration can override this value.

totalDuration number <optional>
0

If specified, each Tween in the Timeline will get an equal portion of this duration, usually in milliseconds, by default. Each individual Tween configuration can override the Tween's duration.

duration number <optional>
1000

If totalDuration is not specified, the default duration, usually in milliseconds, of each Tween which will be created. Each individual Tween configuration can override the Tween's duration.

delay number <optional>
0

The number of milliseconds to delay before the tween will start. Each individual Tween configuration can override this value.

easeParams array <optional>

Optional easing parameters. Each individual Tween configuration can override this value.

ease string | function <optional>
'Power0'

The easing equation to use for each tween. Each individual Tween configuration can override this value.

hold number <optional>
0

The number of milliseconds to hold each tween before yoyo'ing. Each individual Tween configuration can override this value.

repeat number <optional>
0

The number of times to repeat each tween. Each individual Tween configuration can override this value.

repeatDelay number <optional>
0

The number of milliseconds to pause before each tween will repeat. Each individual Tween configuration can override this value.

yoyo boolean <optional>
false

Should each tween complete, then reverse the values incrementally to get back to the starting tween values? The reverse tweening will also take duration milliseconds to complete. Each individual Tween configuration can override this value.

flipX boolean <optional>
false

Horizontally flip the target of the Tween when it completes (before it yoyos, if set to do so). Only works for targets that support the flipX property. Each individual Tween configuration can override this value.

flipY boolean <optional>
false

Vertically flip the target of the Tween when it completes (before it yoyos, if set to do so). Only works for targets that support the flipY property. Each individual Tween configuration can override this value.

completeDelay number | function | object | array <optional>
0

If specified, the time to wait, usually in milliseconds, before the Timeline completes.

loop number | function | object | array <optional>
0

How many times the Timeline should loop, or -1 to loop indefinitely.

loopDelay number | function | object | array <optional>
0

The time, usually in milliseconds, between each loop.

paused boolean <optional>
false

If true, the Timeline will start paused.

useFrames boolean <optional>
false

If true, all duration in the Timeline will be in frames instead of milliseconds.

callbackScope any <optional>

The default scope (this value) to use for each callback registered by the Timeline Builder. If not specified, the Timeline itself will be used.

onStart Phaser.Types.Tweens.TimelineOnStartCallback <optional>

If specified, the onStart callback for the Timeline, called every time it starts playing.

onStartScope any <optional>

The scope (this value) to use for the onStart callback. If not specified, the callbackScope will be used.

onStartParams array <optional>

Additional arguments to pass to the onStart callback. The Timeline will always be the first argument.

onUpdate Phaser.Types.Tweens.TimelineOnUpdateCallback <optional>

If specified, the onUpdate callback for the Timeline, called every frame it's active, regardless of its Tweens.

onUpdateScope any <optional>

The scope (this value) to use for the onUpdate callback. If not specified, the callbackScope will be used.

onUpdateParams array <optional>

Additional arguments to pass to the onUpdate callback. The Timeline will always be the first argument.

onLoop Phaser.Types.Tweens.TimelineOnLoopCallback <optional>

If specified, the onLoop callback for the Timeline, called every time it loops.

onLoopScope any <optional>

The scope (this value) to use for the onLoop callback. If not specified, the callbackScope will be used.

onLoopParams array <optional>

Additional arguments to pass to the onLoop callback. The Timeline will always be the first argument.

onYoyo Phaser.Types.Tweens.TimelineOnYoyoCallback <optional>

If specified, the onYoyo callback for the Timeline, called every time it yoyos.

onYoyoScope any <optional>

The scope (this value) to use for the onYoyo callback. If not specified, the callbackScope will be used.

onYoyoParams array <optional>

Additional arguments to pass to the onYoyo callback. The first argument will always be null, while the Timeline will always be the second argument.

onComplete Phaser.Types.Tweens.TimelineOnCompleteCallback <optional>

If specified, the onComplete callback for the Timeline, called after it completes.

onCompleteScope any <optional>

The scope (this value) to use for the onComplete callback. If not specified, the callbackScope will be used.

onCompleteParams array <optional>

Additional arguments to pass to the onComplete callback. The Timeline will always be the first argument.

Since: 3.18.0
Source: src/tweens/typedefs/TimelineBuilderConfig.js (Line 1)
See:

TimelineOnCompleteCallback(timeline, param)

Parameters:
Name Type Argument Description
timeline Phaser.Tweens.Timeline

The timeline.

param any <repeatable>

Any value passed in onCompleteParams.

Since: 3.18.0
Source: src/tweens/typedefs/TimelineOnCompleteCallback.js (Line 1)

TimelineOnLoopCallback(timeline, param)

Parameters:
Name Type Argument Description
timeline Phaser.Tweens.Timeline

The timeline.

param any <repeatable>

Any value passed in onLoopParams.

Since: 3.18.0
Source: src/tweens/typedefs/TimelineOnLoopCallback.js (Line 1)

TimelineOnStartCallback(timeline, param)

Parameters:
Name Type Argument Description
timeline Phaser.Tweens.Timeline

The timeline.

param any <repeatable>

Any value passed in onStartParams.

Since: 3.18.0
Source: src/tweens/typedefs/TimelineOnStartCallback.js (Line 1)

TimelineOnUpdateCallback(timeline, param)

Parameters:
Name Type Argument Description
timeline Phaser.Tweens.Timeline

The timeline.

param any <repeatable>

Any value passed in onUpdateParams.

Since: 3.18.0
Source: src/tweens/typedefs/TimelineOnUpdateCallback.js (Line 1)

TimelineOnYoyoCallback(timeline, param)

Parameters:
Name Type Argument Description
timeline Phaser.Tweens.Timeline

The timeline.

param any <repeatable>

Any value passed in onYoyoParams.

Since: 3.18.0
Source: src/tweens/typedefs/TimelineOnYoyoCallback.js (Line 1)

TweenBuilderConfig

Type:
  • object
Properties:
Name Type Argument Default Description
targets any

The object, or an array of objects, to run the tween on.

delay number | function <optional>
0

The number of milliseconds to delay before the tween will start.

duration number <optional>
1000

The duration of the tween in milliseconds.

ease string | function <optional>
'Power0'

The easing equation to use for the tween.

easeParams array <optional>

Optional easing parameters.

hold number <optional>
0

The number of milliseconds to hold the tween for before yoyo'ing.

repeat number <optional>
0

The number of times each property tween repeats.

repeatDelay number <optional>
0

The number of milliseconds to pause before a repeat.

yoyo boolean <optional>
false

Should the tween complete, then reverse the values incrementally to get back to the starting tween values? The reverse tweening will also take duration milliseconds to complete.

flipX boolean <optional>
false

Horizontally flip the target of the Tween when it completes (before it yoyos, if set to do so). Only works for targets that support the flipX property.

flipY boolean <optional>
false

Vertically flip the target of the Tween when it completes (before it yoyos, if set to do so). Only works for targets that support the flipY property.

offset string | number | function | object | array <optional>
null

Used when the Tween is part of a Timeline.

completeDelay string | number | function | object | array <optional>
0

The time the tween will wait before the onComplete event is dispatched once it has completed, in ms.

loop string | number | function | object | array <optional>
0

The number of times the tween will repeat. (A value of 1 means the tween will play twice, as it repeated once.) The first loop starts after every property tween has completed once.

loopDelay string | number | function | object | array <optional>
0

The time the tween will pause before starting either a yoyo or returning to the start for a repeat.

paused boolean <optional>
false

Does the tween start in a paused state (true) or playing (false)?

props Object.<string, (number|string|Phaser.Types.Tweens.GetEndCallback|Phaser.Types.Tweens.TweenPropConfig)> <optional>

The properties to tween.

useFrames boolean <optional>
false

Use frames or milliseconds?

callbackScope any <optional>

Scope (this) for the callbacks. The default scope is the tween.

onComplete Phaser.Types.Tweens.TweenOnCompleteCallback <optional>

A function to call when the tween completes.

onCompleteParams array <optional>

Additional parameters to pass to onComplete.

onCompleteScope any <optional>

Scope (this) for onComplete.

onLoop Phaser.Types.Tweens.TweenOnLoopCallback <optional>

A function to call each time the tween loops.

onLoopParams array <optional>

Additional parameters to pass to onLoop.

onLoopScope any <optional>

Scope (this) for onLoop.

onRepeat Phaser.Types.Tweens.TweenOnRepeatCallback <optional>

A function to call each time the tween repeats. Called once per property per target.

onRepeatParams array <optional>

Additional parameters to pass to onRepeat.

onRepeatScope any <optional>

Scope (this) for onRepeat.

onStart Phaser.Types.Tweens.TweenOnStartCallback <optional>

A function to call when the tween starts playback, after any delays have expired.

onStartParams array <optional>

Additional parameters to pass to onStart.

onStartScope any <optional>

Scope (this) for onStart.

onStop Phaser.Types.Tweens.TweenOnStopCallback <optional>

A function to call when the tween is stopped.

onStopParams array <optional>

Additional parameters to pass to onStop.

onStopScope any <optional>

Scope (this) for onStop.

onUpdate Phaser.Types.Tweens.TweenOnUpdateCallback <optional>

A function to call each time the tween steps. Called once per property per target.

onUpdateParams array <optional>

Additional parameters to pass to onUpdate.

onUpdateScope any <optional>

Scope (this) for onUpdate.

onYoyo Phaser.Types.Tweens.TweenOnYoyoCallback <optional>

A function to call each time the tween yoyos. Called once per property per target.

onYoyoParams array <optional>

Additional parameters to pass to onYoyo.

onYoyoScope any <optional>

Scope (this) for onYoyo.

onActive Phaser.Types.Tweens.TweenOnActiveCallback <optional>

A function to call when the tween becomes active within the Tween Manager.

onActiveParams array <optional>

Additional parameters to pass to onActive.

onActiveScope any <optional>

Scope (this) for onActive.

Since: 3.18.0
Source: src/tweens/typedefs/TweenBuilderConfig.js (Line 1)
Example
{
  targets: null,
  delay: 0,
  duration: 1000,
  ease: 'Power0',
  easeParams: null,
  hold: 0,
  repeat: 0,
  repeatDelay: 0,
  yoyo: false,
  flipX: false,
  flipY: false
};

TweenConfigDefaults

Type:
  • object
Properties:
Name Type Argument Default Description
targets object | Array.<object>

The object, or an array of objects, to run the tween on.

delay number <optional>
0

The number of milliseconds to delay before the tween will start.

duration number <optional>
1000

The duration of the tween in milliseconds.

ease string <optional>
'Power0'

The easing equation to use for the tween.

easeParams array <optional>

Optional easing parameters.

hold number <optional>
0

The number of milliseconds to hold the tween for before yoyo'ing.

repeat number <optional>
0

The number of times to repeat the tween.

repeatDelay number <optional>
0

The number of milliseconds to pause before a tween will repeat.

yoyo boolean <optional>
false

Should the tween complete, then reverse the values incrementally to get back to the starting tween values? The reverse tweening will also take duration milliseconds to complete.

flipX boolean <optional>
false

Horizontally flip the target of the Tween when it completes (before it yoyos, if set to do so). Only works for targets that support the flipX property.

flipY boolean <optional>
false

Vertically flip the target of the Tween when it completes (before it yoyos, if set to do so). Only works for targets that support the flipY property.

Since: 3.0.0
Source: src/tweens/tween/Defaults.js (Line 7)

TweenDataConfig

Type:
  • object
Properties:
Name Type Argument Default Description
target any

The target to tween.

index number

The target index within the Tween targets array.

key string

The property of the target being tweened.

getActiveValue Phaser.Types.Tweens.GetActiveCallback <nullable>

If not null, is invoked immediately as soon as the TweenData is running, and is set on the target property.

getEndValue Phaser.Types.Tweens.GetEndCallback

The returned value sets what the property will be at the END of the Tween.

getStartValue Phaser.Types.Tweens.GetStartCallback

The returned value sets what the property will be at the START of the Tween.

ease function

The ease function this tween uses.

duration number <optional>
0

Duration of the tween in ms/frames, excludes time for yoyo or repeats.

totalDuration number <optional>
0

The total calculated duration of this TweenData (based on duration, repeat, delay and yoyo)

delay number <optional>
0

Time in ms/frames before tween will start.

yoyo boolean <optional>
false

Cause the tween to return back to its start value after hold has expired.

hold number <optional>
0

Time in ms/frames the tween will pause before running the yoyo or starting a repeat.

repeat number <optional>
0

Number of times to repeat the tween. The tween will always run once regardless, so a repeat value of '1' will play the tween twice.

repeatDelay number <optional>
0

Time in ms/frames before the repeat will start.

flipX boolean <optional>
false

Automatically call toggleFlipX when the TweenData yoyos or repeats

flipY boolean <optional>
false

Automatically call toggleFlipY when the TweenData yoyos or repeats

progress number <optional>
0

Between 0 and 1 showing completion of this TweenData.

elapsed number <optional>
0

Delta counter

repeatCounter number <optional>
0

How many repeats are left to run?

start number <optional>
0

The property value at the start of the ease.

current number <optional>
0

The current propety value.

previous number <optional>
0

The previous property value.

end number <optional>
0

The property value at the end of the ease.

t1 number <optional>
0

Time duration 1.

t2 number <optional>
0

Time duration 2.

gen Phaser.Types.Tweens.TweenDataGenConfig <optional>

LoadValue generation functions.

state number <optional>
0

TWEEN_CONST.CREATED

Since: 3.0.0
Source: src/tweens/typedefs/TweenDataConfig.js (Line 1)

TweenDataGenConfig

Type:
  • object
Properties:
Name Type Description
delay function

Time in ms/frames before tween will start.

duration function

Duration of the tween in ms/frames, excludes time for yoyo or repeats.

hold function

Time in ms/frames the tween will pause before running the yoyo or starting a repeat.

repeat function

Number of times to repeat the tween. The tween will always run once regardless, so a repeat value of '1' will play the tween twice.

repeatDelay function

Time in ms/frames before the repeat will start.

Since: 3.0.0
Source: src/tweens/typedefs/TweenDataGenConfig.js (Line 1)

TweenOnActiveCallback(tween, target, param)

Parameters:
Name Type Argument Description
tween Phaser.Tweens.Tween

The tween.

target any

The tween target.

param any <repeatable>

Any value passed in onActiveParams.

Since: 3.19.0
Source: src/tweens/typedefs/TweenOnActiveCallback.js (Line 1)

TweenOnCompleteCallback(tween, targets, param)

Parameters:
Name Type Argument Description
tween Phaser.Tweens.Tween

The tween.

targets array

The tween targets.

param any <repeatable>

Any value passed in onCompleteParams.

Since: 3.18.0
Source: src/tweens/typedefs/TweenOnCompleteCallback.js (Line 1)

TweenOnLoopCallback(tween, targets, param)

Parameters:
Name Type Argument Description
tween Phaser.Tweens.Tween

The tween.

targets array

The tween targets.

param any <repeatable>

Any value passed in onLoopParams.

Since: 3.18.0
Source: src/tweens/typedefs/TweenOnLoopCallback.js (Line 1)

TweenOnRepeatCallback(tween, target, param)

Parameters:
Name Type Argument Description
tween Phaser.Tweens.Tween

The tween.

target any

The tween target.

param any <repeatable>

Any value passed in onRepeatParams.

Since: 3.18.0
Source: src/tweens/typedefs/TweenOnRepeatCallback.js (Line 1)

TweenOnStartCallback(tween, targets, param)

Parameters:
Name Type Argument Description
tween Phaser.Tweens.Tween

The tween.

targets array

The tween targets.

param any <repeatable>

Any value passed in onStartParams.

Since: 3.18.0
Source: src/tweens/typedefs/TweenOnStartCallback.js (Line 1)

TweenOnStopCallback(tween, targets, param)

Parameters:
Name Type Argument Description
tween Phaser.Tweens.Tween

The tween.

targets array

The tween targets.

param any <repeatable>

Any value passed in onStopParams.

Since: 3.24.0
Source: src/tweens/typedefs/TweenOnStopCallback.js (Line 1)

TweenOnUpdateCallback(tween, target, param)

Parameters:
Name Type Argument Description
tween Phaser.Tweens.Tween

The tween.

target any

The tween target.

param any <repeatable>

Any value passed in onUpdateParams.

Since: 3.18.0
Source: src/tweens/typedefs/TweenOnUpdateCallback.js (Line 1)

TweenOnYoyoCallback(tween, target, param)

Parameters:
Name Type Argument Description
tween Phaser.Tweens.Tween

The tween.

target any

The tween target.

param any <repeatable>

Any value passed in onYoyoParams.

Since: 3.18.0
Source: src/tweens/typedefs/TweenOnYoyoCallback.js (Line 1)

TweenPropConfig

Type:
  • object
Properties:
Name Type Argument Description
value number | string | Phaser.Types.Tweens.GetEndCallback | Phaser.Types.Tweens.TweenPropConfig <optional>

What the property will be at the END of the Tween.

getActive Phaser.Types.Tweens.GetActiveCallback <optional>

What the property will be set to immediately when this tween becomes active.

getEnd Phaser.Types.Tweens.GetEndCallback <optional>

What the property will be at the END of the Tween.

getStart Phaser.Types.Tweens.GetStartCallback <optional>

What the property will be at the START of the Tween.

ease string | function <optional>

The ease function this tween uses.

delay number <optional>

Time in ms/frames before tween will start.

duration number <optional>

Duration of the tween in ms/frames.

yoyo boolean <optional>

Determines whether the tween should return back to its start value after hold has expired.

hold number <optional>

Time in ms/frames the tween will pause before repeating or returning to its starting value if yoyo is set to true.

repeat number <optional>

Number of times to repeat the tween. The tween will always run once regardless, so a repeat value of '1' will play the tween twice.

repeatDelay number <optional>

Time in ms/frames before the repeat will start.

flipX boolean <optional>

Should toggleFlipX be called when yoyo or repeat happens?

flipY boolean <optional>

Should toggleFlipY be called when yoyo or repeat happens?

Since: 3.18.0
Source: src/tweens/typedefs/TweenPropConfig.js (Line 1)