Phaser API Documentation

  Version: 
Filter
Namespace: Animations
Phaser.Types.Animations

Type Definitions

Animation
Focus
Focus
Properties:
name type arguments Default description
key string <optional>

The key that the animation will be associated with. i.e. sprite.animations.play(key)

frames string | Array.<Phaser.Types.Animations.AnimationFrame> <optional>

Either a string, in which case it will use all frames from a texture with the matching key, or an array of Animation Frame configuration objects.

sortFrames boolean <optional> true

If you provide a string for frames you can optionally have the frame names numerically sorted.

defaultTextureKey string <optional> null

The key of the texture all frames of the animation will use. Can be overridden on a per frame basis.

frameRate number <optional>

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

duration number <optional>

How long the animation should play for in milliseconds. If not given its derived from frameRate.

skipMissedFrames boolean <optional> true

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

delay number <optional> 0

Delay before starting playback. Value given in milliseconds.

repeat number <optional> 0

Number of times to repeat the animation (-1 for infinity)

repeatDelay number <optional> 0

Delay before the animation repeats. Value given in milliseconds.

yoyo boolean <optional> false

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

showOnStart boolean <optional> false

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

hideOnComplete boolean <optional> false

Should sprite.visible = false when the animation finishes?

Type:
object
Since: 3.0.0
Focus
Focus
AnimationFrame
Focus
Focus
Properties:
name type arguments description
key string <optional>

The key of the texture within the Texture Manager to use for this Animation Frame.

frame string | number <optional>

The key, or index number, of the frame within the texture to use for this Animation Frame.

duration number <optional>

The duration, in ms, of this frame of the animation.

visible boolean <optional>

Should the parent Game Object be visible during this frame of the animation?

Type:
object
Since: 3.0.0
Focus
Focus
GenerateFrameNames
Focus
Focus
Properties:
name type arguments Default description
prefix string <optional> ''

The string to append to every resulting frame name if using a range or an array of frames.

start number <optional> 0

If frames is not provided, the number of the first frame to return.

end number <optional> 0

If frames is not provided, the number of the last frame to return.

suffix string <optional> ''

The string to append to every resulting frame name if using a range or an array of frames.

zeroPad number <optional> 0

The minimum expected lengths of each resulting frame's number. Numbers will be left-padded with zeroes until they are this long, then prepended and appended to create the resulting frame name.

outputArray Array.<Phaser.Types.Animations.AnimationFrame> <optional> []

The array to append the created configuration objects to.

frames boolean | Array.<number> <optional> false

If provided as an array, the range defined by start and end will be ignored and these frame numbers will be used.

Type:
object
Since: 3.0.0
Focus
Focus
GenerateFrameNumbers
Focus
Focus
Properties:
name type arguments Default description
start number <optional> 0

The starting frame of the animation.

end number <optional> -1

The ending frame of the animation.

first boolean | number <optional> false

A frame to put at the beginning of the animation, before start or outputArray or frames.

outputArray Array.<Phaser.Types.Animations.AnimationFrame> <optional> []

An array to concatenate the output onto.

frames boolean | Array.<number> <optional> false

A custom sequence of frames.

Type:
object
Focus
Focus
JSONAnimation
Focus
Focus
Properties:
name type description
key string

The key that the animation will be associated with. i.e. sprite.animations.play(key)

type string

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

frames Array.<Phaser.Types.Animations.JSONAnimationFrame>

An array of the AnimationFrame objects inside this Animation.

frameRate number

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

duration number

How long the animation should play for in milliseconds. If not given its derived from frameRate.

skipMissedFrames boolean

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

delay number

Delay before starting playback. Value given in milliseconds.

repeat number

Number of times to repeat the animation (-1 for infinity)

repeatDelay number

Delay before the animation repeats. Value given in milliseconds.

yoyo boolean

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

showOnStart boolean

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

hideOnComplete boolean

Should sprite.visible = false when the animation finishes?

Type:
object
Since: 3.0.0
Focus
Focus
JSONAnimationFrame
Focus
Focus
Properties:
name type description
key string

The key of the Texture this AnimationFrame uses.

frame string | number

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

duration number

Additional time (in ms) that this frame should appear for during playback.

Type:
object
Since: 3.0.0
Focus
Focus
JSONAnimations
Focus
Focus
Properties:
name type description
anims Array.<Phaser.Types.Animations.JSONAnimation>

An array of all Animations added to the Animation Manager.

globalTimeScale number

The global time scale of the Animation Manager.

Type:
object
Since: 3.0.0
Focus
Focus
PlayAnimationConfig
Focus
Focus
Properties:
name type arguments description
key string | Phaser.Animations.Animation

The string-based key of the animation to play, or an Animation instance.

frameRate number <optional>

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

duration number <optional>

How long the animation should play for in milliseconds. If not given its derived from frameRate.

delay number <optional>

Delay before starting playback. Value given in milliseconds.

repeat number <optional>

Number of times to repeat the animation (-1 for infinity)

repeatDelay number <optional>

Delay before the animation repeats. Value given in milliseconds.

yoyo boolean <optional>

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

showOnStart boolean <optional>

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

hideOnComplete boolean <optional>

Should sprite.visible = false when the animation finishes?

startFrame number <optional>

The frame of the animation to start playback from.

timeScale number <optional>

The time scale to be applied to playback of this animation.

Type:
object
Since: 3.50.0
Focus
Focus