Defined in Module impact.animation, inherits from ig.Class
// Create animation var animSheet = new ig.AnimationSheet( 'sheet.png', 16, 16 ); var anim = new ig.Animation( animSheet, 0.1, [0,1,2,3,2,1] ); // Update animation to current frame anim.update(); // Draw current frame anim.draw( x, y );
ig.Animation object takes care of animating an Entity or Background Map tile. Frames from an animation sheet – an image with all animation frames – are drawn as specified by the animations
Read more in the Animations Tutorial.
sheetAn ig.AnimationSheet object specifying the image to use and the width and height of each frame
frameTimeTime in seconds each frame is displayed
sequenceAn Array of integers, specifying the actual animation frames
stopA Boolean, indicating whether to stop the animation when it has reached the last frame. Defaults to
Alpha opacity of the animation from
1. The default is
1 (fully opaque).
New in 1.15
Rotation of the animation in radians. The center of rotation is specified by .pivot.
Booleans, indicating whether the animation should be drawn flipped on the x and/or y axis
The current frame number, set by the
An integer, specifying how often the animation has been played through since the last call to
Note that even if the animation has stopped at the last frame, the
.loopCount is updated as if the animation was still running.
New in 1.15
Center of the rotation when using .angle. The default is half the
.height of the AnimationSheet, i.e. the center of the animation frame.
The current tile of the animation sheet, set by the
Draws the current animation frame at the given screen coordinates
Jumps to frame number
Jumps to a random frame
Rewinds the animation to its first frame and resets the
This method returns the animation itself. This is useful when switching between animations. E.g:
// In an entities .update() method this.currentAnim = this.anims.jump.rewind();
Updates the animation to the current frame, based on its