Phaser API Documentation



Creates a new Animation that is local specifically to this Sprite.

When a Sprite owns an animation, it is kept out of the global Animation Manager, which means you're free to use keys that may be already defined there. Unless you specifically need a Sprite to have a unique animation, you should favor using global animations instead, as they allow for the same animation to be used across multiple Sprites, saving on memory. However, if this Sprite is the only one to use this animation, it's sensible to create it here.

If an invalid key is given this method will return false.

If you pass the key of an animation that already exists locally, that animation will be returned.

A brand new animation is only created if the key is valid and not already in use by this Sprite.

If you wish to re-use an existing key, call the remove method first, then this method.


name type description
config Phaser.Types.Animations.Animation

The configuration settings for the Animation.


The Animation that was created, or false if the key is already in use.

Since: 3.50.0