TiledAnimation
Hierarchy
- Animation
- TiledAnimation
Index
Constructors
Properties
Accessors
Methods
Constructors
constructor
Parameters
options: GraphicOptions & Omit<AnimationOptions, frames> & TiledAnimationOptions
Returns TiledAnimation
Properties
publicevents
publicframeDuration
publicframes
readonlyid
publicopacity
Gets or sets the opacity of the graphic, 0 is transparent, 1 is solid (opaque).
publicready
publicshowDebug
Gets or sets wether to show debug information about the graphic
publicstrategy
publicoptionaltint
publictransform
Accessors
publiccanFinish
Returns
true
if the animation can endReturns boolean
publiccurrentFrame
Returns the current Frame of the animation
Use Animation.currentFrameIndex to get the frame number and Animation.goToFrame to set the current frame index
Returns Frame
publiccurrentFrameIndex
Returns the current frame index of the animation
Use Animation.currentFrame to grab the current Frame object
Returns number
publiccurrentFrameTimeLeft
Returns the amount of time in milliseconds left in the current frame
Returns number
publicdirection
Returns the current play direction of the animation
Returns AnimationDirection
publicdone
Returns
true
if the animation is done, for looping type animationsex.AnimationStrategy.PingPong
andex.AnimationStrategy.Loop
this will always returnfalse
See the
ex.Animation.canFinish()
method to know if an animation type can endReturns boolean
publicflipHorizontal
Gets or sets the flipHorizontal, which will flip the graphic horizontally (across the y axis)
Returns boolean
Parameters
value: boolean
Returns void
publicflipVertical
Gets or sets the flipVertical, which will flip the graphic vertically (across the x axis)
Returns boolean
Parameters
value: boolean
Returns void
height
Gets or sets the height of the graphic (always positive)
Returns number
Parameters
height: number
Returns void
publicisPlaying
Returns
true
if the animation is playingReturns boolean
publicisReversed
Returns boolean
publiclocalBounds
Gets a copy of the bounds in pixels occupied by the graphic on the the screen. This includes scale.
Returns BoundingBox
publicorigin
publicrotation
Gets or sets the rotation of the graphic
Returns number
Parameters
value: number
Returns void
publicscale
sourceView
Returns Partial<SourceView>
Parameters
sourceView: Partial<SourceView>
Returns void
publicspeed
Current animation speed
1 meaning normal 1x speed. 2 meaning 2x speed and so on.
Returns number
Current animation speed
1 meaning normal 1x speed. 2 meaning 2x speed and so on.
Parameters
val: number
Returns void
width
Gets or sets the width of the graphic (always positive)
Returns number
Parameters
width: number
Returns void
Methods
publicclone
Returns a new instance of the graphic that has the same properties
Returns Animation
publiccloneGraphicOptions
Returns GraphicOptions
publicdraw
Draw the whole graphic to the context including transform
Parameters
ex: ExcaliburGraphicsContext
The excalibur graphics context
x: number
y: number
Returns void
publicgoToFrame
Jump the animation immediately to a specific frame if it exists
Optionally specify an override for the duration of the frame, useful for keeping multiple animations in sync with one another.
Parameters
frameNumber: number
optionalduration: number
Returns void
publicisStale
Returns boolean
publicpause
Pauses the animation on the current frame
Returns void
publicplay
Plays or resumes the animation from the current frame
Returns void
publicreset
Reset the animation back to the beginning, including if the animation were done
Returns void
publicreverse
Reverses the play direction of the Animation, this preserves the current frame
Returns void
publictick
Called internally by Excalibur to update the state of the animation potential update the current frame
Parameters
elapsed: number
Milliseconds elapsed
idempotencyToken: number = 0
Prevents double ticking in a frame by passing a unique token to the frame
Returns void
publicstaticfromAnimation
Parameters
animation: Animation
optionaloptions: Omit<TiledAnimationOptions, animation>
Returns TiledAnimation
publicstaticfromSpriteSheet
Create an Animation from a SpriteSheet, a list of indices into the sprite sheet, a duration per frame and optional AnimationStrategy
Example:
const spriteSheet = SpriteSheet.fromImageSource({...}); const anim = Animation.fromSpriteSheet(spriteSheet, range(0, 5), 200, AnimationStrategy.Loop);
Parameters
spriteSheet: SpriteSheet
ex.SpriteSheet
spriteSheetIndex: number[]
0 based index from left to right, top down (row major order) of the ex.SpriteSheet
durationPerFrame: number
duration per frame in milliseconds
strategy: AnimationStrategy = AnimationStrategy.Loop
Optional strategy, default AnimationStrategy.Loop
Returns Animation
publicstaticfromSpriteSheetCoordinates
Create an Animation from a SpriteSheet given a list of coordinates
Example:
const spriteSheet = SpriteSheet.fromImageSource({...}); const anim = Animation.fromSpriteSheetCoordinates({ spriteSheet, frameCoordinates: [ {x: 0, y: 5, duration: 100, options { flipHorizontal: true }}, {x: 1, y: 5, duration: 200}, {x: 2, y: 5}, {x: 3, y: 5} ], strategy: AnimationStrategy.PingPong });
Parameters
options: FromSpriteSheetOptions
Returns Animation
Animation
Create an Animation given a list of
frames
in AnimationOptionsTo create an Animation from a SpriteSheet, use Animation.fromSpriteSheet