Skip to main content
Version: Phaser v4.0.0-rc.6

Types.Animations

Animation

<static> Animation

nametypeoptionaldefaultdescription
keystringYesThe key that the animation will be associated with. i.e. sprite.animations.play(key)
framesstring | Array.<Phaser.Types.Animations.AnimationFrame>YesEither 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.
sortFramesbooleanYestrueIf you provide a string for frames you can optionally have the frame names numerically sorted.
defaultTextureKeystringYesnullThe key of the texture all frames of the animation will use. Can be overridden on a per frame basis.
frameRatenumberYesThe frame rate of playback in frames per second (default 24 if duration is null)
durationnumberYesHow long the animation should play for in milliseconds. If not given its derived from frameRate.
skipMissedFramesbooleanYestrueSkip frames if the time lags, or always advanced anyway?
delaynumberYes0Delay before starting playback. Value given in milliseconds.
repeatnumberYes0Number of times to repeat the animation (-1 for infinity)
repeatDelaynumberYes0Delay before the animation repeats. Value given in milliseconds.
yoyobooleanYesfalseShould the animation yoyo? (reverse back down to the start) before repeating?
showBeforeDelaybooleanYesfalseIf this animation has a delay, should it show the first frame immediately (true), or only after the delay (false)
showOnStartbooleanYesfalseShould sprite.visible = true when the animation starts to play? This happens after any delay, if set.
hideOnCompletebooleanYesfalseShould sprite.visible = false when the animation finishes?
randomFramebooleanYesfalseStart playback of this animation from a randomly selected frame?

Type: object

Member of: Phaser.Types.Animations

Source: src/animations/typedefs/Animation.js#L1
Since: 3.0.0


AnimationFrame

<static> AnimationFrame

nametypeoptionaldefaultdescription
keystringYesThe key of the texture within the Texture Manager to use for this Animation Frame.
framestring | numberYesThe key, or index number, of the frame within the texture to use for this Animation Frame.
durationnumberYes0The duration, in ms, of this frame of the animation.
visiblebooleanYesShould the parent Game Object be visible during this frame of the animation?

Type: object

Member of: Phaser.Types.Animations

Source: src/animations/typedefs/AnimationFrame.js#L1
Since: 3.0.0


GenerateFrameNames

<static> GenerateFrameNames

nametypeoptionaldefaultdescription
prefixstringYes"''"The string to append to every resulting frame name if using a range or an array of frames.
startnumberYes0If frames is not provided, the number of the first frame to return.
endnumberYes0If frames is not provided, the number of the last frame to return.
suffixstringYes"''"The string to append to every resulting frame name if using a range or an array of frames.
zeroPadnumberYes0The 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.
outputArrayArray.<Phaser.Types.Animations.AnimationFrame>Yes"[]"The array to append the created configuration objects to.
framesboolean | Array.<number>YesfalseIf provided as an array, the range defined by start and end will be ignored and these frame numbers will be used.

Type: object

Member of: Phaser.Types.Animations

Source: src/animations/typedefs/GenerateFrameNames.js#L1
Since: 3.0.0


GenerateFrameNumbers

<static> GenerateFrameNumbers

nametypeoptionaldefaultdescription
startnumberYes0The starting frame of the animation.
endnumberYes-1The ending frame of the animation.
firstboolean | numberYesfalseA frame to put at the beginning of the animation, before start or outputArray or frames.
outputArrayArray.<Phaser.Types.Animations.AnimationFrame>Yes"[]"An array to concatenate the output onto.
framesboolean | Array.<number>YesfalseA custom sequence of frames.

Type: object

Member of: Phaser.Types.Animations

Source: src/animations/typedefs/GenerateFrameNumbers.js#L1
Since: 3.0.0


JSONAnimation

<static> JSONAnimation

nametypeoptionaldescription
keystringNoThe key that the animation will be associated with. i.e. sprite.animations.play(key)
typestringNoA frame based animation (as opposed to a bone based animation)
framesArray.<Phaser.Types.Animations.JSONAnimationFrame>NoAn array of the AnimationFrame objects inside this Animation.
frameRatenumberNoThe frame rate of playback in frames per second (default 24 if duration is null)
durationnumberNoHow long the animation should play for in milliseconds. If not given its derived from frameRate.
skipMissedFramesbooleanNoSkip frames if the time lags, or always advanced anyway?
delaynumberNoDelay before starting playback. Value given in milliseconds.
repeatnumberNoNumber of times to repeat the animation (-1 for infinity)
repeatDelaynumberNoDelay before the animation repeats. Value given in milliseconds.
yoyobooleanNoShould the animation yoyo? (reverse back down to the start) before repeating?
showBeforeDelaybooleanNoIf this animation has a delay, should it show the first frame immediately (true), or only after the delay (false)
showOnStartbooleanNoShould sprite.visible = true when the animation starts to play?
hideOnCompletebooleanNoShould sprite.visible = false when the animation finishes?
randomFramebooleanYesStart playback of this animation from a randomly selected frame?

Type: object

Member of: Phaser.Types.Animations

Source: src/animations/typedefs/JSONAnimation.js#L1
Since: 3.0.0


JSONAnimationFrame

<static> JSONAnimationFrame

nametypeoptionaldescription
keystringNoThe key of the Texture this AnimationFrame uses.
framestring | numberNoThe key of the Frame within the Texture that this AnimationFrame uses.
durationnumberNoAdditional time (in ms) that this frame should appear for during playback.

Type: object

Member of: Phaser.Types.Animations

Source: src/animations/typedefs/JSONAnimationFrame.js#L1
Since: 3.0.0


JSONAnimations

<static> JSONAnimations

nametypeoptionaldescription
animsArray.<Phaser.Types.Animations.JSONAnimation>NoAn array of all Animations added to the Animation Manager.
globalTimeScalenumberNoThe global time scale of the Animation Manager.

Type: object

Member of: Phaser.Types.Animations

Source: src/animations/typedefs/JSONAnimations.js#L1
Since: 3.0.0


PlayAnimationConfig

<static> PlayAnimationConfig

nametypeoptionaldescription
keystring | Phaser.Animations.AnimationNoThe string-based key of the animation to play, or an Animation instance.
frameRatenumberYesThe frame rate of playback in frames per second (default 24 if duration is null)
durationnumberYesHow long the animation should play for in milliseconds. If not given its derived from frameRate.
delaynumberYesDelay before starting playback. Value given in milliseconds.
repeatnumberYesNumber of times to repeat the animation (-1 for infinity)
repeatDelaynumberYesDelay before the animation repeats. Value given in milliseconds.
yoyobooleanYesShould the animation yoyo? (reverse back down to the start) before repeating?
showBeforeDelaybooleanYesIf this animation has a delay, should it show the first frame immediately (true), or only after the delay (false)
showOnStartbooleanYesShould sprite.visible = true when the animation starts to play?
hideOnCompletebooleanYesShould sprite.visible = false when the animation finishes?
skipMissedFramesbooleanYesSkip frames if the time lags, or always advanced anyway?
startFramenumberYesThe frame of the animation to start playback from.
timeScalenumberYesThe time scale to be applied to playback of this animation.
randomFramebooleanYesStart playback of this animation from a randomly selected frame?

Type: object

Member of: Phaser.Types.Animations

Source: src/animations/typedefs/PlayAnimationConfig.js#L1
Since: 3.50.0