BaseTweenData
BaseTweenData is the class that the TweenData and TweenFrameData classes
extend from. You should not typically instantiate this class directly, but instead
use it to form your own tween data classes from, should you require it.
Prior to Phaser 3.60 the TweenData was just an object, but was refactored to a class,
to make it responsible for its own state and updating.
Constructor
new BaseTweenData(tween, targetIndex, key, getEnd, getStart, getActive, ease, delay, duration, yoyo, hold, repeat, repeatDelay, flipX, flipY, interpolation, interpolationData)
Parameters
| name | type | optional | description |
|---|---|---|---|
| tween | Phaser.Tweens.Tween | No | The tween this TweenData instance belongs to. |
| targetIndex | number | No | The target index within the Tween targets array. |
| key | string | No | The property of the target to tween. |
| getEnd | Phaser.Types.Tweens.GetEndCallback | No | What the property will be at the END of the Tween. |
| getStart | Phaser.Types.Tweens.GetStartCallback | No | What the property will be at the START of the Tween. |
| getActive | Phaser.Types.Tweens.GetActiveCallback | No | If not null, is invoked immediately as soon as the TweenData is running, and is set on the target property. |
| ease | function | No | The ease function this tween uses. |
| delay | function | No | Function that returns the time in milliseconds before tween will start. |
| duration | number | No | The duration of the tween in milliseconds. |
| yoyo | boolean | No | Determines whether the tween should return back to its start value after hold has expired. |
| hold | number | No | 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 | No | 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 | No | Function that returns the time in milliseconds before the repeat will start. |
| flipX | boolean | No | Should toggleFlipX be called when yoyo or repeat happens? |
| flipY | boolean | No | Should toggleFlipY be called when yoyo or repeat happens? |
| interpolation | function | No | The interpolation function to be used for arrays of data. Defaults to 'null'. |
| interpolationData | Array.<number> | No | The array of interpolation data to be set. Defaults to 'null'. |
Scope: static
Source: src/tweens/tween/BaseTweenData.js#L11
Since: 3.60.0
Public Members
delay
delay: number
Description:
The time, in milliseconds, before this tween will start playing.
This value is generated by the getDelay function.
Source: src/tweens/tween/BaseTweenData.js#L88
Since: 3.60.0
duration
duration: number
Description:
The duration of the tween in milliseconds, excluding any time required
for yoyo or repeats. A tween can never have a duration of zero, so this
will be set to 0.01 if the value is incorrectly less than or equal to zero.
Source: src/tweens/tween/BaseTweenData.js#L67
Since: 3.60.0
elapsed
elapsed: number
Description:
The amount of time, in milliseconds, that has elapsed since this
TweenData was made active.
Source: src/tweens/tween/BaseTweenData.js#L191
Since: 3.60.0
flipX
flipX: boolean
Description:
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.
Source: src/tweens/tween/BaseTweenData.js#L160
Since: 3.60.0
flipY
flipY: boolean
Description:
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.
Source: src/tweens/tween/BaseTweenData.js#L171
Since: 3.60.0
getDelay
getDelay: function
Description:
This function returns the value to be used for TweenData.delay.
Source: src/tweens/tween/BaseTweenData.js#L99
Since: 3.60.0
hold
hold: number
Description:
The time, in milliseconds, before this tween will start a yoyo to repeat.
Source: src/tweens/tween/BaseTweenData.js#L118
Since: 3.60.0
isCountdown
isCountdown: boolean
Description:
Is this Tween Data currently waiting for a countdown to elapse, or not?
Source: src/tweens/tween/BaseTweenData.js#L210
Since: 3.60.0
progress
progress: number
Description:
A value between 0 and 1 holding the progress of this TweenData.
Source: src/tweens/tween/BaseTweenData.js#L182
Since: 3.60.0
repeat
repeat: number
Description:
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.
Source: src/tweens/tween/BaseTweenData.js#L127
Since: 3.60.0
repeatCounter
repeatCounter: number
Description:
How many repeats are left to run?
Source: src/tweens/tween/BaseTweenData.js#L151
Since: 3.60.0
repeatDelay
repeatDelay: number
Description:
The time, in milliseconds, before the repeat will start.
Source: src/tweens/tween/BaseTweenData.js#L142
Since: 3.60.0
state
state: Phaser.Tweens.StateType
Description:
The state of this TweenData.
Source: src/tweens/tween/BaseTweenData.js#L201
Since: 3.60.0
targetIndex
targetIndex: number
Description:
The index of the target within the Tween targets array.
Source: src/tweens/tween/BaseTweenData.js#L58
Since: 3.60.0
totalDuration
totalDuration: number
Description:
The total calculated duration, in milliseconds, of this TweenData.
Factoring in the duration, repeats, delays and yoyos.
Source: src/tweens/tween/BaseTweenData.js#L78
Since: 3.60.0
tween
tween: Phaser.Tweens.Tween
Description:
A reference to the Tween that this TweenData instance belongs to.
Source: src/tweens/tween/BaseTweenData.js#L49
Since: 3.60.0
yoyo
yoyo: boolean
Description:
Will the Tween ease back to its starting values, after reaching the end
and any hold value that may be set?
Source: src/tweens/tween/BaseTweenData.js#L108
Since: 3.60.0
Public Methods
destroy
<instance> destroy()
Description:
Immediately destroys this TweenData, nulling of all its references.
Source: src/tweens/tween/BaseTweenData.js#L653
Since: 3.60.0
getTarget
<instance> getTarget()
Description:
Returns a reference to the target object belonging to this TweenData.
Returns: object - The target object. Can be any JavaScript object, but is typically a Game Object.
Source: src/tweens/tween/BaseTweenData.js#L220
Since: 3.60.0
isComplete
<instance> isComplete()
Description:
Returns true if this TweenData has a current state of COMPLETE, otherwise false.
Returns: boolean - true if this TweenData has a current state of COMPLETE, otherwise false.
Source: src/tweens/tween/BaseTweenData.js#L435
Since: 3.60.0
isCreated
<instance> isCreated()
Description:
Returns true if this TweenData has a current state of CREATED, otherwise false.
Returns: boolean - true if this TweenData has a current state of CREATED, otherwise false.
Source: src/tweens/tween/BaseTweenData.js#L344
Since: 3.60.0
isDelayed
<instance> isDelayed()
Description:
Returns true if this TweenData has a current state of DELAY, otherwise false.
Returns: boolean - true if this TweenData has a current state of DELAY, otherwise false.
Source: src/tweens/tween/BaseTweenData.js#L357
Since: 3.60.0
isHolding
<instance> isHolding()
Description:
Returns true if this TweenData has a current state of HOLD_DELAY, otherwise false.
Returns: boolean - true if this TweenData has a current state of HOLD_DELAY, otherwise false.
Source: src/tweens/tween/BaseTweenData.js#L409
Since: 3.60.0
isPendingRender
<instance> isPendingRender()
Description:
Returns true if this TweenData has a current state of PENDING_RENDER, otherwise false.
Returns: boolean - true if this TweenData has a current state of PENDING_RENDER, otherwise false.
Source: src/tweens/tween/BaseTweenData.js#L370
Since: 3.60.0
isPlayingBackward
<instance> isPlayingBackward()
Description:
Returns true if this TweenData has a current state of PLAYING_BACKWARD, otherwise false.
Returns: boolean - true if this TweenData has a current state of PLAYING_BACKWARD, otherwise false.
Source: src/tweens/tween/BaseTweenData.js#L396
Since: 3.60.0
isPlayingForward
<instance> isPlayingForward()
Description:
Returns true if this TweenData has a current state of PLAYING_FORWARD, otherwise false.
Returns: boolean - true if this TweenData has a current state of PLAYING_FORWARD, otherwise false.
Source: src/tweens/tween/BaseTweenData.js#L383
Since: 3.60.0
isRepeating
<instance> isRepeating()
Description:
Returns true if this TweenData has a current state of REPEAT_DELAY, otherwise false.
Returns: boolean - true if this TweenData has a current state of REPEAT_DELAY, otherwise false.
Source: src/tweens/tween/BaseTweenData.js#L422
Since: 3.60.0
onRepeat
<instance> onRepeat(diff, setStart, isYoyo)
Description:
Internal method that handles repeating or yoyo'ing this TweenData.
Called automatically by setStateFromStart and setStateFromEnd.
Parameters:
| name | type | optional | description |
|---|---|---|---|
| diff | number | No | Any extra time that needs to be accounted for in the elapsed and progress values. |
| setStart | boolean | No | Set the TweenData start values? |
| isYoyo | boolean | No | Is this call a Yoyo check? |
Fires: Phaser.Tweens.Events#event:TWEEN_REPEAT, Phaser.Tweens.Events#event:TWEEN_YOYO
Source: src/tweens/tween/BaseTweenData.js#L570
Since: 3.60.0
reset
<instance> reset()
Description:
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.
Source: src/tweens/tween/BaseTweenData.js#L497
Since: 3.60.0
setCompleteState
<instance> setCompleteState()
Description:
Sets this TweenData state to COMPLETE.
Source: src/tweens/tween/BaseTweenData.js#L332
Since: 3.60.0
setCreatedState
<instance> setCreatedState()
Description:
Sets this TweenData state to CREATED.
Source: src/tweens/tween/BaseTweenData.js#L248
Since: 3.60.0
setDelayState
<instance> setDelayState()
Description:
Sets this TweenData state to DELAY.
Source: src/tweens/tween/BaseTweenData.js#L260
Since: 3.60.0
setHoldState
<instance> setHoldState()
Description:
Sets this TweenData state to HOLD_DELAY.
Source: src/tweens/tween/BaseTweenData.js#L308
Since: 3.60.0
setPendingRenderState
<instance> setPendingRenderState()
Description:
Sets this TweenData state to PENDING_RENDER.
Source: src/tweens/tween/BaseTweenData.js#L272
Since: 3.60.0
setPlayingBackwardState
<instance> setPlayingBackwardState()
Description:
Sets this TweenData state to PLAYING_BACKWARD.
Source: src/tweens/tween/BaseTweenData.js#L296
Since: 3.60.0
setPlayingForwardState
<instance> setPlayingForwardState()
Description:
Sets this TweenData state to PLAYING_FORWARD.
Source: src/tweens/tween/BaseTweenData.js#L284
Since: 3.60.0
setRepeatState
<instance> setRepeatState()
Description:
Sets this TweenData state to REPEAT_DELAY.
Source: src/tweens/tween/BaseTweenData.js#L320
Since: 3.60.0
setStateFromEnd
<instance> setStateFromEnd(diff)
Description:
Internal method used as part of the playback process that checks if this
TweenData should yoyo, repeat, or has completed.
Parameters:
| name | type | optional | description |
|---|---|---|---|
| diff | number | No | Any extra time that needs to be accounted for in the elapsed and progress values. |
Fires: Phaser.Tweens.Events#event:TWEEN_REPEAT, Phaser.Tweens.Events#event:TWEEN_YOYO
Source: src/tweens/tween/BaseTweenData.js#L448
Since: 3.60.0
setStateFromStart
<instance> setStateFromStart(diff)
Description:
Internal method used as part of the playback process that checks if this
TweenData should repeat or has completed.
Parameters:
| name | type | optional | description |
|---|---|---|---|
| diff | number | No | Any extra time that needs to be accounted for in the elapsed and progress values. |
Fires: Phaser.Tweens.Events#event:TWEEN_REPEAT
Source: src/tweens/tween/BaseTweenData.js#L475
Since: 3.60.0
setTargetValue
<instance> setTargetValue([value])
Description:
Sets this TweenData's target object property to be the given value.
Parameters:
| name | type | optional | description |
|---|---|---|---|
| value | number | Yes | The value to set on the target. If not given, sets it to the last current value. |
Source: src/tweens/tween/BaseTweenData.js#L233
Since: 3.60.0