Skip to main content

Animation.js

Animation

A class to animate a sprite

Kind: global class

new Animation(parent, name, startFrame, numberOfFrames, speed, [loop])

ParamTypeDefaultDescription
parentImpacto.GameObjects.Sprite

The parent Sprite.

namestring

The name of the Animations.

startFramenumber

The first frame of the Animations.

numberOfFramesnumber

Number of frames of the Animations.

speednumber

The speed of the Animations.

[loop]booleantrue

Whether the Animations should loop or not.

Example

new Animation(MySprite, "Default", 0, 10, 100, true);

Animation.setName(newName) ⇒ Animation

Change the current animation name

Kind: static method of Animation
Returns: Animation -

The animation state

ParamTypeDescription
newNamestring

The

Example

const myAnimation = new Animation(MySprite, "MyAnimation" , 0, 10, 100).setName("MyNewName");

Animation.setSpeed(name, speed) ⇒ Animation

Change the speed of a animation

Kind: static method of Animation
Returns: Animation -

The animation state

ParamTypeDescription
namestring

The name of the Animation.

speednumber

The new speed of the Animation.

Example

const myAnimation = new Animation(MySprite, "MyAnimation" , 0, 10, 100).setSpeed(50);

Animation.setStartFrame(startFrame) ⇒ Animation

Change the start frame of a animation

Kind: static method of Animation
Returns: Animation -

The animation state

ParamTypeDescription
startFramenumber

The new start frame of the Animation.

Example

const myAnimation = new Animation(MySprite, "MyAnimation" , 0, 10, 100).setStartFrame(5);

Animation.setNumberOfFrames(numberOfFrames) ⇒ Animation

Change the number of frames of a animation

Kind: static method of Animation
Returns: Animation -

The animation state

ParamTypeDescription
numberOfFramesnumber

The new number of frames of the Animation.

Example

const myAnimation = new Animation(MySprite, "MyAnimation" , 0, 10, 100).setNumberOfFrames(5);

Animation.setLoop(loop) ⇒ Animation

Change the loop of a animation

Kind: static method of Animation
Returns: Animation -

The animation state

ParamTypeDescription
loopboolean

The new loop of the Animation.

Example

const myAnimation = new Animation(MySprite, "MyAnimation" , 0, 10, 100, true).setLoop(false);

Animation.reset() ⇒ Animation

Reset the animation to the first frame

Kind: static method of Animation
Returns: Animation -

The animation state


Example

const myAnimation = new Animation(MySprite, "MyAnimation" , 0, 10, 100).reset();