ch2.Animation is used to display a parametrized sequence of bitmap tiles on the screen. This is more powerful version than h2d.Anim, but requires more setup.
Constructor
new (?frames:Array<AnimationFrame>, ?parent:Object)
Create a new animation with the specified frames and parent object
Variables
currentFrame:Int
The current frame the animation is currently playing. Always in [0,frames.length]
range
read onlyduration:Float
Duration of current animation. Affected by speed
variable, for duration of frame use static getDuration
function.
read onlyframes:Array<AnimationFrame>
The current animation, as a list of AnimationFrame instances to display.
pause:Bool = false
Setting pause will pause the animation, preventing any automatic change to currentFrame.
playWhenHidden:Bool = false
Enables playback of animation even when visible = false
. (default: false)
Does not check for nested visibility.
Methods
dynamiconAnimEnd ():Void
onAnimEnd is automatically called each time the animation will reach past the last frame.
If loop is true, it is called everytime the animation loops.
If loop is false, it is called once when the animation reachs currentFrame == frames.length
play (frames:Array<AnimationFrame>, atFrame:Int = 0):Void
Change the currently playing animation and unset the pause if it was set.
Static methods
staticfromDurationList (tiles:Array<Tile>, durations:Array<Float>):Array<AnimationFrame>
Create an array from list of tiles and their durations. Both arrays should be the same length.
staticfromFixedFramerate (tiles:Array<Tile>, fps:Float):Array<AnimationFrame>
Create an array of frames with fixed framerate. Will produce same playback result as h2d.Anim.