Namespace: Events

Phaser.Animations. Events

Events


ADD_ANIMATION

The Add Animation Event.

This event is dispatched when a new animation is added to the global Animation Manager.

This can happen either as a result of an animation instance being added to the Animation Manager, or the Animation Manager creating a new animation directly.

Parameters:
Name Type Description
key string

The key of the Animation that was added to the global Animation Manager.

animation Phaser.Animations.Animation

An instance of the newly created Animation.

Source: src/animations/events/ADD_ANIMATION_EVENT.js (Line 7)

ANIMATION_COMPLETE

The Animation Complete Event.

This event is dispatched by an Animation instance when it completes, i.e. finishes playing or is manually stopped.

Be careful with the volume of events this could generate. If a group of Sprites all complete the same animation at the same time, this event will invoke its handler for each one of them.

Parameters:
Name Type Description
animation Phaser.Animations.Animation

A reference to the Animation that completed.

frame Phaser.Animations.AnimationFrame

The current Animation Frame that the Animation completed on.

gameObject Phaser.GameObjects.Sprite

A reference to the Game Object on which the animation completed.

Source: src/animations/events/ANIMATION_COMPLETE_EVENT.js (Line 7)

ANIMATION_REPEAT

The Animation Repeat Event.

This event is dispatched when a currently playing animation repeats.

The event is dispatched directly from the Animation object itself. Which means that listeners bound to this event will be invoked every time the Animation repeats, for every Game Object that may have it.

Parameters:
Name Type Description
animation Phaser.Animations.Animation

A reference to the Animation that repeated.

frame Phaser.Animations.AnimationFrame

The current Animation Frame that the Animation was on when it repeated.

Source: src/animations/events/ANIMATION_REPEAT_EVENT.js (Line 7)

ANIMATION_RESTART

The Animation Restart Event.

This event is dispatched by an Animation instance when it restarts.

Be careful with the volume of events this could generate. If a group of Sprites all restart the same animation at the same time, this event will invoke its handler for each one of them.

Parameters:
Name Type Description
animation Phaser.Animations.Animation

A reference to the Animation that restarted playing.

frame Phaser.Animations.AnimationFrame

The current Animation Frame that the Animation restarted with.

gameObject Phaser.GameObjects.Sprite

A reference to the Game Object on which the animation restarted playing.

Source: src/animations/events/ANIMATION_RESTART_EVENT.js (Line 7)

ANIMATION_START

The Animation Start Event.

This event is dispatched by an Animation instance when it starts playing.

Be careful with the volume of events this could generate. If a group of Sprites all play the same animation at the same time, this event will invoke its handler for each one of them.

Parameters:
Name Type Description
animation Phaser.Animations.Animation

A reference to the Animation that started playing.

frame Phaser.Animations.AnimationFrame

The current Animation Frame that the Animation started with.

gameObject Phaser.GameObjects.Sprite

A reference to the Game Object on which the animation started playing.

Source: src/animations/events/ANIMATION_START_EVENT.js (Line 7)

PAUSE_ALL

The Pause All Animations Event.

This event is dispatched when the global Animation Manager is told to pause.

When this happens all current animations will stop updating, although it doesn't necessarily mean that the game has paused as well.

Source: src/animations/events/PAUSE_ALL_EVENT.js (Line 7)

REMOVE_ANIMATION

The Remove Animation Event.

This event is dispatched when an animation is removed from the global Animation Manager.

Parameters:
Name Type Description
key string

The key of the Animation that was removed from the global Animation Manager.

animation Phaser.Animations.Animation

An instance of the removed Animation.

Source: src/animations/events/REMOVE_ANIMATION_EVENT.js (Line 7)

RESUME_ALL

The Resume All Animations Event.

This event is dispatched when the global Animation Manager resumes, having been previously paused.

When this happens all current animations will continue updating again.

Source: src/animations/events/RESUME_ALL_EVENT.js (Line 7)

SPRITE_ANIMATION_COMPLETE

The Sprite Animation Complete Event.

This event is dispatched by a Sprite when an animation finishes playing on it.

Listen for it on the Sprite using sprite.on('animationcomplete', listener)

This same event is dispatched for all animations. To listen for a specific animation, use the SPRITE_ANIMATION_KEY_COMPLETE event.

Parameters:
Name Type Description
animation Phaser.Animations.Animation

A reference to the Animation that completed.

frame Phaser.Animations.AnimationFrame

The current Animation Frame that the Animation completed on.

gameObject Phaser.GameObjects.Sprite

A reference to the Game Object on which the animation completed.

Source: src/animations/events/SPRITE_ANIMATION_COMPLETE_EVENT.js (Line 7)

SPRITE_ANIMATION_KEY_COMPLETE

The Sprite Animation Key Complete Event.

This event is dispatched by a Sprite when a specific animation finishes playing on it.

Listen for it on the Sprite using sprite.on('animationcomplete-key', listener) where key is the key of the animation. For example, if you had an animation with the key 'explode' you should listen for animationcomplete-explode.

Parameters:
Name Type Description
animation Phaser.Animations.Animation

A reference to the Animation that completed.

frame Phaser.Animations.AnimationFrame

The current Animation Frame that the Animation completed on.

gameObject Phaser.GameObjects.Sprite

A reference to the Game Object on which the animation completed.

Source: src/animations/events/SPRITE_ANIMATION_KEY_COMPLETE_EVENT.js (Line 7)

SPRITE_ANIMATION_KEY_REPEAT

The Sprite Animation Key Repeat Event.

This event is dispatched by a Sprite when a specific animation repeats playing on it.

Listen for it on the Sprite using sprite.on('animationrepeat-key', listener) where key is the key of the animation. For example, if you had an animation with the key 'explode' you should listen for animationrepeat-explode.

Parameters:
Name Type Description
animation Phaser.Animations.Animation

A reference to the Animation that is repeating on the Sprite.

frame Phaser.Animations.AnimationFrame

The current Animation Frame that the Animation started with.

repeatCount integer

The number of times the Animation has repeated so far.

gameObject Phaser.GameObjects.Sprite

A reference to the Game Object on which the animation repeated playing.

Source: src/animations/events/SPRITE_ANIMATION_KEY_REPEAT_EVENT.js (Line 7)

SPRITE_ANIMATION_KEY_RESTART

The Sprite Animation Key Restart Event.

This event is dispatched by a Sprite when a specific animation restarts playing on it.

Listen for it on the Sprite using sprite.on('animationrestart-key', listener) where key is the key of the animation. For example, if you had an animation with the key 'explode' you should listen for animationrestart-explode.

Parameters:
Name Type Description
animation Phaser.Animations.Animation

A reference to the Animation that was restarted on the Sprite.

frame Phaser.Animations.AnimationFrame

The current Animation Frame that the Animation restarted with.

gameObject Phaser.GameObjects.Sprite

A reference to the Game Object on which the animation restarted playing.

Source: src/animations/events/SPRITE_ANIMATION_KEY_RESTART_EVENT.js (Line 7)

SPRITE_ANIMATION_KEY_START

The Sprite Animation Key Start Event.

This event is dispatched by a Sprite when a specific animation starts playing on it.

Listen for it on the Sprite using sprite.on('animationstart-key', listener) where key is the key of the animation. For example, if you had an animation with the key 'explode' you should listen for animationstart-explode.

Parameters:
Name Type Description
animation Phaser.Animations.Animation

A reference to the Animation that was started on the Sprite.

frame Phaser.Animations.AnimationFrame

The current Animation Frame that the Animation started with.

gameObject Phaser.GameObjects.Sprite

A reference to the Game Object on which the animation started playing.

Source: src/animations/events/SPRITE_ANIMATION_KEY_START_EVENT.js (Line 7)

SPRITE_ANIMATION_KEY_UPDATE

The Sprite Animation Key Update Event.

This event is dispatched by a Sprite when a specific animation playing on it updates. This happens when the animation changes frame, based on the animation frame rate and other factors like timeScale and delay.

Listen for it on the Sprite using sprite.on('animationupdate-key', listener) where key is the key of the animation. For example, if you had an animation with the key 'explode' you should listen for animationupdate-explode.

Parameters:
Name Type Description
animation Phaser.Animations.Animation

A reference to the Animation that has updated on the Sprite.

frame Phaser.Animations.AnimationFrame

The current Animation Frame of the Animation.

gameObject Phaser.GameObjects.Sprite

A reference to the Game Object on which the animation updated.

Source: src/animations/events/SPRITE_ANIMATION_KEY_UPDATE_EVENT.js (Line 7)

SPRITE_ANIMATION_REPEAT

The Sprite Animation Repeat Event.

This event is dispatched by a Sprite when an animation repeats playing on it.

Listen for it on the Sprite using sprite.on('animationrepeat', listener)

This same event is dispatched for all animations. To listen for a specific animation, use the SPRITE_ANIMATION_KEY_REPEAT event.

Parameters:
Name Type Description
animation Phaser.Animations.Animation

A reference to the Animation that is repeating on the Sprite.

frame Phaser.Animations.AnimationFrame

The current Animation Frame that the Animation started with.

repeatCount integer

The number of times the Animation has repeated so far.

gameObject Phaser.GameObjects.Sprite

A reference to the Game Object on which the animation repeated playing.

Source: src/animations/events/SPRITE_ANIMATION_REPEAT_EVENT.js (Line 7)

SPRITE_ANIMATION_RESTART

The Sprite Animation Restart Event.

This event is dispatched by a Sprite when an animation restarts playing on it.

Listen for it on the Sprite using sprite.on('animationrestart', listener)

This same event is dispatched for all animations. To listen for a specific animation, use the SPRITE_ANIMATION_KEY_RESTART event.

Parameters:
Name Type Description
animation Phaser.Animations.Animation

A reference to the Animation that was restarted on the Sprite.

frame Phaser.Animations.AnimationFrame

The current Animation Frame that the Animation restarted with.

gameObject Phaser.GameObjects.Sprite

A reference to the Game Object on which the animation restarted playing.

Source: src/animations/events/SPRITE_ANIMATION_RESTART_EVENT.js (Line 7)

SPRITE_ANIMATION_START

The Sprite Animation Start Event.

This event is dispatched by a Sprite when an animation starts playing on it.

Listen for it on the Sprite using sprite.on('animationstart', listener)

This same event is dispatched for all animations. To listen for a specific animation, use the SPRITE_ANIMATION_KEY_START event.

Parameters:
Name Type Description
animation Phaser.Animations.Animation

A reference to the Animation that was started on the Sprite.

frame Phaser.Animations.AnimationFrame

The current Animation Frame that the Animation started with.

gameObject Phaser.GameObjects.Sprite

A reference to the Game Object on which the animation started playing.

Source: src/animations/events/SPRITE_ANIMATION_START_EVENT.js (Line 7)

SPRITE_ANIMATION_UPDATE

The Sprite Animation Update Event.

This event is dispatched by a Sprite when an animation playing on it updates. This happens when the animation changes frame, based on the animation frame rate and other factors like timeScale and delay.

Listen for it on the Sprite using sprite.on('animationupdate', listener)

This same event is dispatched for all animations. To listen for a specific animation, use the SPRITE_ANIMATION_KEY_UPDATE event.

Parameters:
Name Type Description
animation Phaser.Animations.Animation

A reference to the Animation that has updated on the Sprite.

frame Phaser.Animations.AnimationFrame

The current Animation Frame of the Animation.

gameObject Phaser.GameObjects.Sprite

A reference to the Game Object on which the animation updated.

Source: src/animations/events/SPRITE_ANIMATION_UPDATE_EVENT.js (Line 7)