Class: Animation

Animation(filename, rows, cols, frameDuration, loop)

An Animation is similar to a Texture but designed for drawing images from a spritesheet (a grid of images), with methods to automatically update

Constructor

new Animation(filename, rows, cols, frameDuration, loop)

Load image file and create list of regions depending on number of rows and columns in spritesheet.
Parameters:
Name Type Description
filename string the name (including path) of the image file
rows number the number of rows in the spritesheet
cols number the number of columns in the spritesheet
frameDuration number time (seconds) to display each frame (region in spritesheet)
loop boolean whether to restart animation once all frames have been displayed
Source:

Methods

clone() → {Animation}

Make a copy of this object.
An animation object can not be shared between multiple sprites because each may have started at different times, thus have different elapsedTime values.
Source:
Returns:
a copy of this Animation object
Type
Animation

isFinished() → {boolean}

Determines if this animation is finished displaying all frames (and is not set to loop).
Source:
Returns:
if this animation has finished
Type
boolean

update()

Updates elapsedTime and updates the rectangular region used by texture depending on how much time has elapsed.
Source: