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.

read onlyheight:Int

Total height of the animation. Accounts for all frames.

@:value(true)loop:Bool = true

Disabling loop will stop the animation at the last frame (default : true)

@:value(false)pause:Bool = false

Setting pause will pause the animation, preventing any automatic change to currentFrame.

@:value(false)playWhenHidden:Bool = false

Enables playback of animation even when visible = false. (default: false) Does not check for nested visibility.

@:value(1.)speed:Float = 1.

Playback speed multiplier for animation (default : 1)

read onlywidth:Int

Total width of the animation. Accounts for all frames.

Methods

inlinegetFrame ():AnimationFrame

Returns current AnimationFrame being played.

getTile ():Tile

Returns current h2d.Tile being played.

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

dynamiconEvent (name:String):Void

Triggers when frame contains event string

@:value({ frame : 0 })palyAt (frame:Int = 0):Void

Starts animation playback at specified frame.

@:value({ atFrame : 0 })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.

staticgetDuration (frames:Array<AnimationFrame>):Float

Returns total duration of animation frames.