Phaser API Documentation

  Version: 
chain(key)

Description:

Sets an animation, or an array of animations, to be played immediately after the current one completes or stops.

The current animation must enter a 'completed' state for this to happen, i.e. finish all of its repeats, delays, etc, or have the stop method called directly on it.

An animation set to repeat forever will never enter a completed state.

You can chain a new animation at any point, including before the current one starts playing, during it, or when it ends (via its animationcomplete event).

Chained animations are specific to a Game Object, meaning different Game Objects can have different chained animations without impacting the animation they're playing.

Call this method with no arguments to reset all currently chained animations.

When playing an animation on a Sprite it will first check to see if it can find a matching key locally within the Sprite. If it can, it will play the local animation. If not, it will then search the global Animation Manager and look for it there.

Parameters:

name type description
key string | Array.<string> | Phaser.Animations.Animation | Array.<Phaser.Animations.Animation> | Phaser.Types.Animations.PlayAnimationConfig | Array.<Phaser.Types.Animations.PlayAnimationConfig>

The string-based key of the animation to play, or an Animation instance, or a PlayAnimationConfig object, or an array of them.

Returns:
Description:

This Game Object.

Since: 3.50.0