Create a new sprite animation.
Animation configuration.
Index into the frames array (not the frame value itself).
true once a non-looping animation has played its last frame.
Accumulated time for the current frame (seconds).
ReadonlyframeHeight of a single frame in the sprite sheet, in pixels.
ReadonlyframesOrdered array of frame indices into the sprite sheet.
ReadonlyframeWidth of a single frame in the sprite sheet, in pixels.
Whether the animation loops back to the first frame after finishing.
Playback speed in frames per second.
Return the current frame index value from the frames array.
The sprite-sheet frame index for the current animation state.
Compute SpriteOptions source-rectangle fields for the current frame, given the total width of the sprite sheet.
The frame index is mapped to a grid position assuming frames are arranged left-to-right, top-to-bottom in the sheet.
Total width of the sprite sheet image in pixels.
A SpriteOptions object with sourceX, sourceY,
sourceWidth, and sourceHeight populated.
Reset the animation to the first frame. Also clears the done flag for non-looping animations.
Advance the animation by dt seconds.
Handles frame skipping correctly - if dt is large enough to span
multiple frames (e.g. after a hitch), all intermediate frames are
consumed so the animation stays in sync with wall-clock time.
Delta time in seconds since the last update.
Tracks and updates sprite-sheet animation state.
Manages frame timing, looping, and generates SpriteOptions source rectangles suitable for passing directly to
drawSprite().Remarks
The
update()method correctly handles large delta times by advancing through multiple frames when necessary (e.g. after a frame hitch).Example