Class: Animation

Phaser.Animations. Animation

A Frame based Animation.

This consists of a key, some default values (like the frame rate) and a bunch of Frame objects.

The Animation Manager creates these. Game Objects don't own an instance of these directly.
Game Objects have the Animation Component, which are like playheads to global Animations (these objects)
So multiple Game Objects can have playheads all pointing to this one Animation instance.


new Animation(manager, key, config)

Parameters:
Name Type Description
manager Phaser.Animations.AnimationManager

[description]

key string

[description]

config AnimationConfig

[description]

Since: 3.0.0
Source: src/animations/Animation.js (Line 56)

Members


delay :integer

The delay in ms before the playback will begin.

Type:
  • integer
Since: 3.0.0
Default Value:
  • 0
Source: src/animations/Animation.js (Line 183)

duration :integer

How long the animation should play for, in milliseconds.
If the frameRate property has been set then it overrides this value,
otherwise the frameRate is derived from duration.

Type:
  • integer
Since: 3.0.0
Source: src/animations/Animation.js (Line 132)

frameRate :integer

The frame rate of playback in frames per second (default 24 if duration is null)

Type:
  • integer
Since: 3.0.0
Default Value:
  • 24
Source: src/animations/Animation.js (Line 122)

frames :Array.<Phaser.Animations.AnimationFrame>

Extract all the frame data into the frames array

Type:
Since: 3.0.0
Source: src/animations/Animation.js (Line 109)

hideOnComplete :boolean

Should sprite.visible = false when the animation finishes?

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

key :string

The unique identifying string for this animation

Type:
  • string
Since: 3.0.0
Source: src/animations/Animation.js (Line 90)

manager :Phaser.Animations.AnimationManager

A reference to the global Animation Manager

Type:
Since: 3.0.0
Source: src/animations/Animation.js (Line 81)

msPerFrame :integer

How many ms per frame, not including frame specific modifiers.

Type:
  • integer
Since: 3.0.0
Source: src/animations/Animation.js (Line 164)

paused :boolean

Global pause. All Game Objects using this Animation instance are impacted by this property.

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

repeat :integer

Number of times to repeat the animation. Set to -1 to repeat forever.

Type:
  • integer
Since: 3.0.0
Default Value:
  • 0
Source: src/animations/Animation.js (Line 193)

repeatDelay :integer

The delay in ms before the a repeat playthrough starts.

Type:
  • integer
Since: 3.0.0
Default Value:
  • 0
Source: src/animations/Animation.js (Line 203)

showOnStart :boolean

Should sprite.visible = true when the animation starts to play?

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

skipMissedFrames :boolean

Skip frames if the time lags, or always advanced anyway?

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

type :string

A frame based animation (as opposed to a bone based animation)

Type:
  • string
Since: 3.0.0
Default Value:
  • frame
Source: src/animations/Animation.js (Line 99)

yoyo :boolean

Should the animation yoyo? (reverse back down to the start) before repeating?

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

Methods


addFrame(config)

Add frames to the end of the animation.

Parameters:
Name Type Description
config string | Array.<AnimationFrameConfig>

[description]

Since: 3.0.0
Source: src/animations/Animation.js (Line 257)
Returns:

This Animation object.

Type
Phaser.Animations.Animation

addFrameAt(index, config)

Add frame/s into the animation.

Parameters:
Name Type Description
index integer

[description]

config string | Array.<AnimationFrameConfig>

[description]

Since: 3.0.0
Source: src/animations/Animation.js (Line 272)
Returns:

This Animation object.

Type
Phaser.Animations.Animation

checkFrame(index)

Check if the given frame index is valid.

Parameters:
Name Type Description
index integer

The index to be checked.

Since: 3.0.0
Source: src/animations/Animation.js (Line 311)
Returns:

true if the index is valid, otherwise false.

Type
boolean

<protected> completeAnimation(component)

[description]

Parameters:
Name Type Description
component Phaser.GameObjects.Components.Animation

[description]

Since: 3.0.0
Source: src/animations/Animation.js (Line 326)

destroy()

[description]

Since: 3.0.0
Source: src/animations/Animation.js (Line 934)

<protected> getFirstTick(component [, includeDelay])

[description]

Parameters:
Name Type Argument Default Description
component Phaser.GameObjects.Components.Animation

[description]

includeDelay boolean <optional>
true

[description]

Since: 3.0.0
Source: src/animations/Animation.js (Line 345)

<protected> getFrameAt(index)

Returns the AnimationFrame at the provided index

Parameters:
Name Type Description
index integer

The index in the AnimationFrame array

Since: 3.0.0
Source: src/animations/Animation.js (Line 369)
Returns:

The frame at the index provided from the animation sequence

Type
Phaser.Animations.AnimationFrame

getFrameByProgress(value)

Returns the frame closest to the given progress value between 0 and 1.

Parameters:
Name Type Description
value number

A value between 0 and 1.

Since: 3.4.0
Source: src/animations/Animation.js (Line 548)
Returns:

The frame closest to the given progress value.

Type
Phaser.Animations.AnimationFrame

getFrames(textureManager, frames [, defaultTextureKey])

[description]

Parameters:
Name Type Argument Description
textureManager Phaser.Textures.TextureManager

[description]

frames string | Array.<AnimationFrameConfig>

[description]

defaultTextureKey string <optional>

[description]

Since: 3.0.0
Source: src/animations/Animation.js (Line 385)
Returns:

[description]

Type
Array.<Phaser.Animations.AnimationFrame>

getLastFrame()

Returns the animation last frame.

Since: 3.12.0
Source: src/animations/Animation.js (Line 649)
Returns:

component - The Animation Last Frame.

Type
Phaser.Animations.AnimationFrame

getNextTick(component)

[description]

Parameters:
Name Type Description
component Phaser.GameObjects.Components.Animation

[description]

Since: 3.0.0
Source: src/animations/Animation.js (Line 487)

nextFrame(component)

Advance the animation frame.

Parameters:
Name Type Description
component Phaser.GameObjects.Components.Animation

The Animation Component to advance.

Since: 3.0.0
Source: src/animations/Animation.js (Line 565)

pause()

[description]

Since: 3.0.0
Source: src/animations/Animation.js (Line 904)
Returns:

This Animation object.

Type
Phaser.Animations.Animation

previousFrame(component)

[description]

Parameters:
Name Type Description
component Phaser.GameObjects.Components.Animation

[description]

Since: 3.0.0
Source: src/animations/Animation.js (Line 662)

removeFrame(frame)

[description]

Parameters:
Name Type Description
frame Phaser.Animations.AnimationFrame

[description]

Since: 3.0.0
Source: src/animations/Animation.js (Line 725)
Returns:

This Animation object.

Type
Phaser.Animations.Animation

removeFrameAt(index)

Removes a frame from the AnimationFrame array at the provided index
and updates the animation accordingly.

Parameters:
Name Type Description
index integer

The index in the AnimationFrame array

Since: 3.0.0
Source: src/animations/Animation.js (Line 747)
Returns:

This Animation object.

Type
Phaser.Animations.Animation

repeatAnimation(component)

[description]

Parameters:
Name Type Description
component Phaser.GameObjects.Components.Animation

[description]

Since: 3.0.0
Source: src/animations/Animation.js (Line 767)

resume()

[description]

Since: 3.0.0
Source: src/animations/Animation.js (Line 919)
Returns:

This Animation object.

Type
Phaser.Animations.Animation

setFrame(component)

[description]

Parameters:
Name Type Description
component Phaser.GameObjects.Components.Animation

[description]

Since: 3.0.0
Source: src/animations/Animation.js (Line 805)

toJSON()

[description]

Since: 3.0.0
Source: src/animations/Animation.js (Line 826)
Returns:

[description]

Type
JSONAnimation

updateFrameSequence()

[description]

Since: 3.0.0
Source: src/animations/Animation.js (Line 859)
Returns:

This Animation object.

Type
Phaser.Animations.Animation