Performance-optimized animated Image. Can have multiple animations, which draw frames from the provided source image to the screen.
Constructor
new (source : TileType, frameWidth : Int = 0, frameHeight : Int = 0) : Void
Constructor.
Parameters:
source | Source image. | |
frameWidth | Frame width. | |
frameHeight | Frame height. |
Variables
Functions
add (name : String, frames : Array<Int>, frameRate : Float = 0, loop : Bool = true) : Animation
Add an Animation.
Parameters:
name | Name of the animation. | |
frames | Array of frame indices to animate through. | |
frameRate | Animation speed (in frames per second, 0 defaults to assigned frame rate) | |
loop | If the animation should loop |
Returns:
A new Anim object for the animation.
play (name : String = "", reset : Bool = false, reverse : Bool = false) : Animation
Plays an animation previous defined by add().
Parameters:
name | Name of the animation to play. | |
reset | If the animation should force-restart if it is already playing. | |
reverse | If the animation should be played backward. |
Returns:
Anim object representing the played animation.
playAnimation (anim : Animation, reset : Bool = false, reverse : Bool = false) : Animation
Plays or restarts the supplied Animation.
Parameters:
animation | The Animation object to play | |
reset | When the supplied animation is currently playing, should it be force-restarted | |
reverse | If the animation should be played backward. |
Returns:
Animation object representing the played animation.
playFrames (frames : Array<Int>, frameRate : Float = 0, loop : Bool = true, reset : Bool = false, reverse : Bool = false) : Animation
Plays a new ad hoc animation.
Parameters:
frames | Array of frame indices to animate through. | |
frameRate | Animation speed (in frames per second, 0 defaults to assigned frame rate) | |
loop | If the animation should loop | |
reset | When the supplied frames are currently playing, should the animation be force-restarted | |
reverse | If the animation should be played backward. |
Returns:
Anim object representing the played animation.
setAnimFrame (name : String, index : Int) : Void
Sets the frame to the frame index of an animation.
Parameters:
name | Animation to draw the frame frame. | |
index | Index of the frame of the animation to set to. |
stop (reset : Bool = false) : Void
Immediately stops the currently playing animation.
Parameters:
reset | If true, resets the animation to the first frame. |