Contains data about a sprite animation.

Available since

0.1.0

.

Constructor

@:value({ defaultDuration : 100, reverse : false })new(name:String, frames:Array<Int>, reverse:Bool = false, defaultDuration:Int = 100)

Creates an nb.Sprite.AnimData instance.

Parameters:

name

A name to identify the animation.

frames

The animation's frame indexes.

reverse

Whether the animation should be played in reverse.

defaultDuration

The default duration of the frames.

Variables

defaultDuration:Int

The animation's default frame duration.

frames:Array<Int>

Contains the animation's frame index for each frame.

framesDuration:Array<Int>

Contains the frame duration for each frame. frameDuration[4] is the frame duration of the 4th frame.

name:String

The animation's name.

@:value(false)once:Bool = false

Whether the animation stop playing at the last frame.

reverse:Bool

Whether the animation should play in reverse.

@:value(null)onFrameEnd:(AnimData, Int) ‑> Int = null

A function that gets called at the end of every frame.

The first argument is the associated animation data, and the second argument the frame that is just stopping to get displayed. Returns the index of the next frame set to be displayed.

onFrameEnd gets called before onFrameStart.

@:value(null)onFrameStart:(AnimData, Int) ‑> Int = null

A function that gets called at the start of every frame.

The first argument is the associated animation data, and the second argument the frame that is just starting to get displayed. Returns the index of the next frame set to be displayed.

onFrameEnd gets called before onFrameStart.