Animation.js
Animation
A class to animate a sprite
Kind: global class
new Animation(parent, name, startFrame, numberOfFrames, speed, [loop])
Param | Type | Default | Description |
---|---|---|---|
parent | Impacto.GameObjects.Sprite | The parent Sprite. | |
name | string | The name of the Animations. | |
startFrame | number | The first frame of the Animations. | |
numberOfFrames | number | Number of frames of the Animations. | |
speed | number | The speed of the Animations. | |
[loop] | boolean | true | 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
Param | Type | Description |
---|---|---|
newName | string | 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
Param | Type | Description |
---|---|---|
name | string | The name of the Animation. |
speed | number | 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
Param | Type | Description |
---|---|---|
startFrame | number | 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
Param | Type | Description |
---|---|---|
numberOfFrames | number | 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
Param | Type | Description |
---|---|---|
loop | boolean | 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();