Phaser API Documentation

generateFrameNames(key, [config])


Generate an array of Phaser.Types.Animations.AnimationFrame objects from a texture key and configuration object.

Generates objects with string based frame names, as configured by the given Phaser.Types.Animations.GenerateFrameNames.

It's a helper method, designed to make it easier for you to extract all of the frame names from texture atlases. If you're working with a sprite sheet, see the generateFrameNumbers method instead.


If you have a texture atlases loaded called gems and it contains 6 frames called ruby_0001, ruby_0002, and so on, then you can call this method using: this.anims.generateFrameNames('gems', { prefix: 'ruby_', end: 6, zeroPad: 4 }).

The end value tells it to look for 6 frames, incrementally numbered, all starting with the prefix ruby_. The zeroPad value tells it how many zeroes pad out the numbers. To create an animation using this method, you can do:

  key: 'ruby',
  repeat: -1,
  frames: this.anims.generateFrameNames('gems', {
    prefix: 'ruby_',
    end: 6,
    zeroPad: 4

Please see the animation examples for further details.


name type arguments description
key string

The key for the texture containing the animation frames.

config Phaser.Types.Animations.GenerateFrameNames <optional>

The configuration object for the animation frame names.


The array of {@link Phaser.Types.Animations.AnimationFrame} objects.

Since: 3.50.0