Phaser API Documentation

generateFrameNumbers(key, config)


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

Generates objects with numbered frame names, as configured by the given Phaser.Types.Animations.GenerateFrameNumbers.

If you're working with a texture atlas, see the generateFrameNames method instead.

It's a helper method, designed to make it easier for you to extract frames from sprite sheets. If you're working with a texture atlas, see the generateFrameNames method instead.


If you have a sprite sheet loaded called explosion and it contains 12 frames, then you can call this method using:

this.anims.generateFrameNumbers('explosion', { start: 0, end: 11 }).

The end value of 11 tells it to stop after the 12th frame has been added, because it started at zero.

To create an animation using this method, you can do:

  key: 'boom',
  frames: this.anims.generateFrameNames('explosion', {
    start: 0,
    end: 11

Note that start is optional and you don't need to include it if the animation starts from frame 0.

To specify an animation in reverse, swap the start and end values.

If the frames are not sequential, you may pass an array of frame numbers instead, for example:

this.anims.generateFrameNumbers('explosion', { frames: [ 0, 1, 2, 1, 2, 3, 4, 0, 1, 2 ] })

Please see the animation examples and GenerateFrameNumbers config docs for further details.


name type description
key string

The key for the texture containing the animation frames.

config Phaser.Types.Animations.GenerateFrameNumbers

The configuration object for the animation frames.


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

Since: 3.0.0