SpriteSheetAnimation
The SpriteSheetAnimation
class represents an animation for a sprite sheet.
Constructor
prototype
constructor(frames: number[], speed: number, loop: boolean = true): void;
Parameters
frames
- Type:
number[]
- The frames of the animation.
- Type:
speed
- Type:
number
- The speed of the animation (in frame per second).
- Type:
loop
(optional)- Type:
boolean
- Default value:
true
- Whether or not the animation should loop.
- Type:
Examples
const animation = new SpriteSheetAnimation([0, 1, 2], 1);
const animation = new SpriteSheetAnimation([0, 1, 2], 1, false);
Getters
frames
- Type:
number[]
Gets the frames of the animation.
loop
- Type:
boolean
Gets whether or not the animation should loop.
isEnded
- Type:
boolean
Gets whether or not the animation has ended.
Getters & Setters
currentFrame
- Type:
number
Gets or sets the current frame of the animation.
Methods
reset
prototype
reset(): void;
Resets the animation.
Return
void
Example
const animation = new SpriteSheetAnimation(/* ... */);
//...
animation.reset();
update
prototype
update(deltaTime: number): void;
Updates the animation.
Parameters
deltaTime
- Type:
number
- The time since the last frame.
- Type:
Return
void
Example
const animation = new SpriteSheetAnimation(/* ... */);
//...
animation.update(deltaTime);