The TweenFrameData is a class that contains a single target that will change the texture frame at the conclusion of the Tween.
TweenFrameData instances are typically created by the TweenBuilder automatically, when it detects the presence of a 'texture' property as the key being tweened.
A Tween can own multiple TweenFrameData instances, but a TweenFrameData only ever belongs to a single Tween.
You should not typically create these yourself, but rather use the TweenBuilder,
or the Tween.addFrame
method.
new TweenFrameData(tween, targetIndex, texture, frame, delay, duration, hold, repeat, repeatDelay, flipX, flipY)
name | type | description |
---|---|---|
tween | Phaser.Tweens.Tween |
The tween this TweenData instance belongs to. |
targetIndex | number |
The target index within the Tween targets array. |
texture | string |
The texture key to set at the end of this tween. |
frame | string | number |
The texture frame to set at the end of this tween. |
delay | function |
Function that returns the time in milliseconds before tween will start. |
duration | number |
The duration of the tween in milliseconds. |
hold | number |
Function that returns the time in milliseconds the tween will pause before repeating or returning to its starting value if yoyo is set to true. |
repeat | number |
Function that returns the 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 |
Function that returns the time in milliseconds before the repeat will start. |
flipX | boolean |
Should toggleFlipX be called when yoyo or repeat happens? |
flipY | boolean |
Should toggleFlipY be called when yoyo or repeat happens? |
The time, in milliseconds, before this tween will start playing.
This value is generated by the getDelay
function.
The duration of the tween in milliseconds, excluding any time required for yoyo or repeats.
The amount of time, in milliseconds, that has elapsed since this TweenData was made active.
The frame to be set at the end of the tween.
The texture to be set at the end of the tween.
If true
this Tween will call toggleFlipX
on the Tween target
whenever it yoyo's or repeats. It will only be called if the target
has a function matching this name, like most Phaser GameObjects do.
If true
this Tween will call toggleFlipY
on the Tween target
whenever it yoyo's or repeats. It will only be called if the target
has a function matching this name, like most Phaser GameObjects do.
This function returns the value to be used for TweenData.delay
.
The time, in milliseconds, before this tween will start a yoyo to repeat.
Is this Tween Data currently waiting for a countdown to elapse, or not?
The property of the target to be tweened.
Always 'texture' for a TweenFrameData object.
A value between 0 and 1 holding the progress of this TweenData.
The number of times this tween will repeat.
The tween will always run once regardless of this value, so a repeat value of '1' will play the tween twice: I.e. the original play-through and then it repeats that once (1).
If this value is set to -1 this tween will repeat forever.
How many repeats are left to run?
The time, in milliseconds, before the repeat will start.
The frame to be set at the start of the tween.
The texture to be set at the start of the tween.
The state of this TweenData.
The index of the target within the Tween targets
array.
The total calculated duration, in milliseconds, of this TweenData. Factoring in the duration, repeats, delays and yoyos.
A reference to the Tween that this TweenData instance belongs to.
Will the Tween ease back to its starting values, after reaching the end
and any hold
value that may be set?
Immediately destroys this TweenData, nulling of all its references.
Internal method that will emit a TweenData based Event on the parent Tween and also invoke the given callback, if provided.
name | type | arguments | description |
---|---|---|---|
event | Phaser.Types.Tweens.Event |
The Event to be dispatched. |
|
callback | Phaser.Types.Tweens.TweenCallbackTypes | <optional> |
The name of the callback to be invoked. Can be |
Returns a reference to the target object belonging to this TweenData.
The target object. Can be any JavaScript object, but is typically a Game Object.
Returns true
if this TweenData has a current state of COMPLETE, otherwise false
.
true
if this TweenData has a current state of COMPLETE, otherwise false
.
Returns true
if this TweenData has a current state of CREATED, otherwise false
.
true
if this TweenData has a current state of CREATED, otherwise false
.
Returns true
if this TweenData has a current state of DELAY, otherwise false
.
true
if this TweenData has a current state of DELAY, otherwise false
.
Returns true
if this TweenData has a current state of HOLD_DELAY, otherwise false
.
true
if this TweenData has a current state of HOLD_DELAY, otherwise false
.
Returns true
if this TweenData has a current state of PENDING_RENDER, otherwise false
.
true
if this TweenData has a current state of PENDING_RENDER, otherwise false
.
Returns true
if this TweenData has a current state of PLAYING_BACKWARD, otherwise false
.
true
if this TweenData has a current state of PLAYING_BACKWARD, otherwise false
.
Returns true
if this TweenData has a current state of PLAYING_FORWARD, otherwise false
.
true
if this TweenData has a current state of PLAYING_FORWARD, otherwise false
.
Returns true
if this TweenData has a current state of REPEAT_DELAY, otherwise false
.
true
if this TweenData has a current state of REPEAT_DELAY, otherwise false
.
Internal method that handles repeating or yoyo'ing this TweenData.
Called automatically by setStateFromStart
and setStateFromEnd
.
name | type | description |
---|---|---|
diff | number |
Any extra time that needs to be accounted for in the elapsed and progress values. |
setStart | boolean |
Set the TweenData start values? |
isYoyo | boolean |
Is this call a Yoyo check? |
Internal method that resets this Tween Data entirely, including the progress and elapsed values.
Called automatically by the parent Tween. Should not be called directly.
name | type | arguments | Default | description |
---|---|---|---|---|
isSeeking | boolean | <optional> | false |
Is the Tween Data being reset as part of a Tween seek? |
Sets this TweenData state to COMPLETE.
Sets this TweenData state to CREATED.
Sets this TweenData state to DELAY.
Sets this TweenData state to HOLD_DELAY.
Sets this TweenData state to PENDING_RENDER.
Sets this TweenData state to PLAYING_BACKWARD.
Sets this TweenData state to PLAYING_FORWARD.
Sets this TweenData state to REPEAT_DELAY.
Internal method used as part of the playback process that checks if this TweenData should yoyo, repeat, or has completed.
name | type | description |
---|---|---|
diff | number |
Any extra time that needs to be accounted for in the elapsed and progress values. |
Internal method used as part of the playback process that checks if this TweenData should repeat or has completed.
name | type | description |
---|---|---|
diff | number |
Any extra time that needs to be accounted for in the elapsed and progress values. |
Sets this TweenData's target object property to be the given value.
name | type | arguments | description |
---|---|---|---|
value | number | <optional> |
The value to set on the target. If not given, sets it to the last |
Internal method that advances this TweenData based on the delta value given.
name | type | description |
---|---|---|
delta | number |
The elapsed delta time in ms. |
true
if this TweenData is still playing, or false
if it has finished entirely.