Skip to main content
Version: Phaser v4.0.0-rc.6

TweenChain

A TweenChain is a special type of Tween that allows you to create a sequence of Tweens, chained to one-another,

and add them to the Tween Manager.

The tweens are played in order, from start to finish. You can optionally set the chain

to repeat as many times as you like. Once the chain has finished playing, or repeating if set,

all tweens in the chain will be destroyed automatically. To override this, set the 'persist'

argument to 'true'.

Playback will start immediately unless the first Tween has been configured to be paused.

Please note that Tweens will not manipulate any target property that begins with an underscore.

Constructor

new TweenChain(parent)

Parameters

nametypeoptionaldescription
parentPhaser.Tweens.TweenManager | Phaser.Tweens.TweenChainNoA reference to the Tween Manager, or TweenChain, that owns this TweenChain.

Scope: static

Extends

Phaser.Tweens.BaseTween

Source: src/tweens/tween/TweenChain.js#L15
Since: 3.60.0

Inherited Members

From Phaser.Tweens.BaseTween:


Public Members

currentIndex

currentIndex: number

Description:

A reference to the data array index of the currently playing tween.

Source: src/tweens/tween/TweenChain.js#L56
Since: 3.60.0


currentTween

currentTween: Phaser.Tweens.Tween

Description:

A reference to the Tween that this TweenChain is currently playing.

Source: src/tweens/tween/TweenChain.js#L47
Since: 3.60.0


Inherited Methods

From Phaser.Events.EventEmitter:

From Phaser.Tweens.BaseTween:

From Phaser.Tweens.TweenChain:


Public Methods

add

<instance> add(tweens)

Description:

Create a sequence of Tweens, chained to one-another, and add them to this Tween Manager.

The tweens are played in order, from start to finish. You can optionally set the chain

to repeat as many times as you like. Once the chain has finished playing, or repeating if set,

all tweens in the chain will be destroyed automatically. To override this, set the 'persist'

argument to 'true'.

Playback will start immediately unless the first Tween has been configured to be paused.

Please note that Tweens will not manipulate any target property that begins with an underscore.

Parameters:

nametypeoptionaldescription
tweensArray.<Phaser.Types.Tweens.TweenBuilderConfig> | Array.<object>NoAn array of Tween configuration objects for the Tweens in this chain.

Returns: Phaser.Tweens.TweenChain - This TweenChain instance.

Source: src/tweens/tween/TweenChain.js#L95
Since: 3.60.0


destroy

<instance> destroy()

Description:

Immediately destroys this TweenChain, nulling of all its references.

Overrides: Phaser.Tweens.BaseTween#destroy

Source: src/tweens/tween/TweenChain.js#L534
Since: 3.60.0


dispatchEvent

<instance> dispatchEvent(event, [callback])

Description:

Internal method that will emit a TweenChain based Event and invoke the given callback.

Parameters:

nametypeoptionaldescription
eventPhaser.Types.Tweens.EventNoThe Event to be dispatched.
callbackPhaser.Types.Tweens.TweenCallbackTypesYesThe name of the callback to be invoked. Can be null or undefined to skip invocation.

Source: src/tweens/tween/TweenChain.js#L513
Since: 3.60.0


hasTarget

<instance> hasTarget(target)

Description:

See if any of the tweens in this Tween Chain is currently acting upon the given target.

Parameters:

nametypeoptionaldescription
targetobjectNoThe target to check against this TweenChain.

Returns: boolean - true if the given target is a target of this TweenChain, otherwise false.

Source: src/tweens/tween/TweenChain.js#L172
Since: 3.60.0


init

<instance> init()

Description:

Prepares this TweenChain for playback.

Called automatically by the TweenManager. Should not be called directly.

Returns: Phaser.Tweens.TweenChain - This TweenChain instance.

Fires: Phaser.Tweens.Events#event:TWEEN_ACTIVE

Source: src/tweens/tween/TweenChain.js#L66
Since: 3.60.0


makeActive

<instance> makeActive(tween)

Description:

Re-initialises the given Tween and sets it to the Active state.

Parameters:

nametypeoptionaldescription
tweenPhaser.Tweens.TweenNoThe Tween to check.

Returns: Phaser.Tweens.TweenChain - This TweenChain instance.

Source: src/tweens/tween/TweenChain.js#L251
Since: 3.60.0


nextState

<instance> nextState()

Description:

Internal method that advances to the next state of the TweenChain playback.

Returns: boolean - true if this TweenChain has completed, otherwise false.

Fires: Phaser.Tweens.Events#event:TWEEN_COMPLETE, Phaser.Tweens.Events#event:TWEEN_LOOP

Source: src/tweens/tween/TweenChain.js#L271
Since: 3.60.0


nextTween

<instance> nextTween()

Description:

Immediately advances to the next Tween in the chain.

This is typically called internally, but can be used if you need to

advance playback for some reason.

Returns: boolean - true if there are no more Tweens in the chain, otherwise false.

Source: src/tweens/tween/TweenChain.js#L468
Since: 3.60.0


play

<instance> play()

Description:

Starts this TweenChain playing.

You only need to call this method if you have configured this TweenChain to be paused on creation.

If the TweenChain is already playing, calling this method again will have no effect. If you wish to

restart the chain, use TweenChain.restart instead.

Calling this method after the TweenChain has completed will start the chain playing again from the beginning.

Returns: Phaser.Tweens.TweenChain - This TweenChain instance.

Source: src/tweens/tween/TweenChain.js#L318
Since: 3.60.0


remove

<instance> remove(tween)

Description:

Removes the given Tween from this Tween Chain.

The removed tween is not destroyed. It is just removed from this Tween Chain.

If the given Tween is currently playing then the chain will automatically move

to the next tween in the chain. If there are no more tweens, this chain will complete.

Parameters:

nametypeoptionaldescription
tweenPhaser.Tweens.TweenNoThe Tween to be removed.

Returns: Phaser.Tweens.TweenChain - This Tween Chain instance.

Source: src/tweens/tween/TweenChain.js#L139
Since: 3.60.0


reset

<instance> reset(tween)

Description:

Resets the given Tween.

It will seek to position 0 and playback will start on the next frame.

Parameters:

nametypeoptionaldescription
tweenPhaser.Tweens.TweenNoThe Tween to be reset.

Returns: Phaser.Tweens.TweenChain - This TweenChain instance.

Source: src/tweens/tween/TweenChain.js#L230
Since: 3.60.0


resetTweens

<instance> resetTweens()

Description:

Internal method that resets all of the Tweens and the current index pointer.

Source: src/tweens/tween/TweenChain.js#L361
Since: 3.60.0


restart

<instance> restart()

Description:

Restarts the TweenChain from the beginning.

If this TweenChain was configured to have a loop, or start delay, those

are reset to their initial values as well. It will also dispatch the

onActive callback and event again.

Returns: Phaser.Tweens.TweenChain - This TweenChain instance.

Source: src/tweens/tween/TweenChain.js#L197
Since: 3.60.0


setCurrentTween

<instance> setCurrentTween(index)

Description:

Sets the current active Tween to the given index, based on its

entry in the TweenChain data array.

Parameters:

nametypeoptionaldescription
indexnumberNoThe index of the Tween to be made current.

Source: src/tweens/tween/TweenChain.js#L495
Since: 3.60.0


update

<instance> update(delta)

Description:

Internal method that advances the TweenChain based on the time values.

Parameters:

nametypeoptionaldescription
deltanumberNoThe delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate.

Returns: boolean - Returns true if this TweenChain has finished and should be removed from the Tween Manager, otherwise returns false.

Fires: Phaser.Tweens.Events#event:TWEEN_COMPLETE, Phaser.Tweens.Events#event:TWEEN_LOOP, Phaser.Tweens.Events#event:TWEEN_START

Source: src/tweens/tween/TweenChain.js#L380
Since: 3.60.0