Constructor
new Animations(target)
Creates a new instance of the Animations class.
Parameters:
Name | Type | Description |
---|---|---|
target |
rune.display.Sprite | The Sprite object to which the animation is linked. |
- Source:
Members
(readonly) current :rune.animation.Animation
Current animation. If this reference is null, no animation has been added.
Type:
- Source:
(readonly) frame :rune.geom.Rectangle
Frame data. This is information that describes which part of the Sprite
object's texture data is to be used for the current animation's current
frame. This reference is primarily intended for internal use, but may be
used for specific purposes.
Type:
- Source:
Methods
add(animation) → {boolean}
Adds an animation. An animation needs to use a unique ID (name) to be added.
If an animation with the same name already exists, the new animation will
not be added.
Parameters:
Name | Type | Description |
---|---|---|
animation |
rune.animation.Animation | Animation to be added. |
- Source:
Throws:
-
If incorrect data type is used.
- Type
- TypeError
Returns:
- Type
- boolean
clear() → {undefined}
Removes all animations.
- Source:
Returns:
- Type
- undefined
create(name, frames, framerate, looped) → {boolean}
Creates a new animation. After an animation is created, it is automatically
added to the animation system.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | The name of the animation. |
frames |
Array.<number> | Frame sequence. |
framerate |
number | Playback speed specified in frames per second. |
looped |
boolean | Whether or not to loop the animation sequence. |
- Source:
Returns:
- Type
- boolean
find(name) → {rune.animation.Animation}
Search for an animation in the animation system by its name. If no animation
is found, null is returned.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | The name of the animation requested. |
- Source:
Returns:
goto(name, frame) → {undefined}
Changes the animation sequence and goes to a specific frame in that sequence.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | Requested animation. |
frame |
number | Frame to go to. |
- Source:
Returns:
- Type
- undefined
gotoAndPlay(name, frame) → {undefined}
Switches animation sequence and goes to a specific frame in that sequence
and resumes playback from there.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | Requested animation. |
frame |
number | Frame to go to. |
- Source:
Returns:
- Type
- undefined
gotoAndStop(name, frame) → {undefined}
Changes the animation sequence and goes to a specific frame in that sequence
and stops playback on that frame.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | Requested animation. |
frame |
number | Frame to go to. |
- Source:
Returns:
- Type
- undefined
gotoNextFrame() → {undefined}
Goes to the next frame in the current animation sequence.
- Source:
Returns:
- Type
- undefined
gotoPreviousFrame() → {undefined}
Goes to the previous frame in the current animation sequence.
- Source:
Returns:
- Type
- undefined
gotoRandomFrame() → {undefined}
Goes to a random frame in the current animation sequence.
- Source:
Returns:
- Type
- undefined
play() → {undefined}
Plays the current animation sequence. If the animation is stopped, playback
resumes from the previous position. If the animation is already playing,
playback continues.
- Source:
Returns:
- Type
- undefined
remove(name) → {boolean}
Removes an animation.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | Animation to remove. |
- Source:
Returns:
- Type
- boolean
stop() → {undefined}
Stops playback of current animation sequence.
- Source:
Returns:
- Type
- undefined