Phaser API Documentation

  Version: 
Filter
This is a beta release of our new docs system. Found an issue?
Please tell us about it in the #📖-newdocs-feedback channel on the Phaser Discord

Phaser . Animations . AnimationFrame

This is a beta release of our new docs system. Found an issue?
Please tell us about it in the #📖-newdocs-feedback channel on the Phaser Discord

Phaser . Animations . AnimationFrame

A single frame in an Animation sequence.

An AnimationFrame consists of a reference to the Texture it uses for rendering, references to other frames in the animation, and index data. It also has the ability to modify the animation timing.

AnimationFrames are generated automatically by the Animation class.

Constructor:

new AnimationFrame(textureKey, textureFrame, index, frame, [isKeyFrame])

Parameters:

name type arguments Default description
textureKey string

The key of the Texture this AnimationFrame uses.

textureFrame string | number

The key of the Frame within the Texture that this AnimationFrame uses.

index number

The index of this AnimationFrame within the Animation sequence.

frame Phaser.Textures.Frame

A reference to the Texture Frame this AnimationFrame uses for rendering.

isKeyFrame boolean <optional> false

Is this Frame a Keyframe within the Animation?

Since: 3.0.0

Members

duration: number
Focus
Focus

Description:

Additional time (in ms) that this frame should appear for during playback. The value is added onto the msPerFrame set by the animation.

Type:
number
Default: 0
Since: 3.0.0
Focus
Focus

Description:

A reference to the Texture Frame this AnimationFrame uses for rendering.

Type:
Since: 3.0.0
Focus
Focus
index: number
Focus
Focus

Description:

The index of this AnimationFrame within the Animation sequence.

Type:
number
Since: 3.0.0
Focus
Focus
<readonly> isFirst: boolean
Focus
Focus

Description:

Is this the first frame in an animation sequence?

Type:
boolean
Default: false
Since: 3.0.0
Focus
Focus
isKeyFrame: boolean
Focus
Focus

Description:

Is this Frame a KeyFrame within the Animation?

Type:
boolean
Since: 3.50.0
Focus
Focus
<readonly> isLast: boolean
Focus
Focus

Description:

Is this the last frame in an animation sequence?

Type:
boolean
Default: false
Since: 3.0.0
Focus
Focus
<readonly, nullable> nextFrame: Phaser.Animations.AnimationFrame
Focus
Focus

Description:

A reference to the AnimationFrame that comes after this one in the animation, if any.

Type:
Default: null
Since: 3.0.0
Focus
Focus
<readonly, nullable> prevFrame: Phaser.Animations.AnimationFrame
Focus
Focus

Description:

A reference to the AnimationFrame that comes before this one in the animation, if any.

Type:
Default: null
Since: 3.0.0
Focus
Focus
<readonly> progress: number
Focus
Focus

Description:

What % through the animation does this frame come? This value is generated when the animation is created and cached here.

Type:
number
Default: 0
Since: 3.0.0
Focus
Focus
textureFrame: string | number
Focus
Focus

Description:

The key of the Frame within the Texture that this AnimationFrame uses.

Type:
string | number
Since: 3.0.0
Focus
Focus
textureKey: string
Focus
Focus

Description:

The key of the Texture this AnimationFrame uses.

Type:
string
Since: 3.0.0
Focus
Focus

Methods

destroy()
Focus
Focus

Description:

Destroys this object by removing references to external resources and callbacks.

Examples:
Since: 3.0.0
Focus
Focus
toJSON()
Focus
Focus

Description:

Generates a JavaScript object suitable for converting to JSON.

Returns:
Description:

The AnimationFrame data.

Examples:
Since: 3.0.0
Focus
Focus