Class: AnimationFrame

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 fire its own onUpdate callback
and modify the animation timing.

AnimationFrames are generated automatically by the Animation class.


new AnimationFrame(textureKey, textureFrame, index, frame)

Parameters:
Name Type Description
textureKey string

The key of the Texture this AnimationFrame uses.

textureFrame string | integer

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

index integer

The index of this AnimationFrame within the Animation sequence.

frame Phaser.Textures.Frame

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

Since: 3.0.0
Source: src/animations/AnimationFrame.js (Line 17)

Members


duration :number

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
Since: 3.0.0
Default Value:
  • 0
Source: src/animations/AnimationFrame.js (Line 123)

frame :Phaser.Textures.Frame

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

Type:
Since: 3.0.0
Source: src/animations/AnimationFrame.js (Line 70)

index :integer

The index of this AnimationFrame within the Animation sequence.

Type:
  • integer
Since: 3.0.0
Source: src/animations/AnimationFrame.js (Line 61)

<readonly> isFirst :boolean

Is this the first frame in an animation sequence?

Type:
  • boolean
Since: 3.0.0
Default Value:
  • false
Source: src/animations/AnimationFrame.js (Line 79)

<readonly> isLast :boolean

Is this the last frame in an animation sequence?

Type:
  • boolean
Since: 3.0.0
Default Value:
  • false
Source: src/animations/AnimationFrame.js (Line 90)

<readonly, nullable> nextFrame :Phaser.Animations.AnimationFrame

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

Type:
Since: 3.0.0
Default Value:
  • null
Source: src/animations/AnimationFrame.js (Line 112)

<readonly, nullable> prevFrame :Phaser.Animations.AnimationFrame

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

Type:
Since: 3.0.0
Default Value:
  • null
Source: src/animations/AnimationFrame.js (Line 101)

<readonly> progress :number

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

Type:
  • number
Since: 3.0.0
Default Value:
  • 0
Source: src/animations/AnimationFrame.js (Line 134)

textureFrame :string|integer

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

Type:
  • string | integer
Since: 3.0.0
Source: src/animations/AnimationFrame.js (Line 52)

textureKey :string

The key of the Texture this AnimationFrame uses.

Type:
  • string
Since: 3.0.0
Source: src/animations/AnimationFrame.js (Line 43)

Methods


destroy()

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

Since: 3.0.0
Source: src/animations/AnimationFrame.js (Line 164)

toJSON()

Generates a JavaScript object suitable for converting to JSON.

Since: 3.0.0
Source: src/animations/AnimationFrame.js (Line 147)
Returns:

The AnimationFrame data.

Type
JSONAnimationFrame