The main class in the library
var sprite:Aseprite = Aseprite.fromBytes(Assets.getBytes('path/to/asepriteAsset.aseprite'));
addChild(sprite);
Static methods
Variables
read onlyonFrame:Array<Int ‑> Void>
An array of function that will be called on every frame change
sprite.onFrame.push((frameIndex:Int) -> {
trace('Frame index changed to: ${frameIndex}');
});
read onlyonTag:Array<Array<String> ‑> Void>
An array of functions that will be called every time tags of the current frame are different from the tags of the previous frame
sprite.onTag.push((tags:Array<String>) -> {
trace('Current tags are: ${tags.join(', ')}');
});
read onlypalette:Palette
Sprite's palette
for(index => color in sprite.palette.entries) {
trace('Paletter entry $index: #${StringTools.hex(color, 6)}');
}
useEnterFrame:Bool
If set to true
will use ENTER_FRAME
event to update the state of the sprite.
Otherwise update time
of the sprite manually
Methods
play(?tagName:String, repeats:Int = -1, ?onFinished:() ‑> Void):Aseprite
Start playing the animation
Parameters:
tagName | Name of the tag to play |
---|---|
repeats | Number of repeats (-1 - infinite) |
onFinished | Callback that will be called when repeats are finished (won't be called if |
spawn(?sliceName:String, ?spriteWidth:Int, ?spriteHeight:Int, ?useEnterFrame:Bool):Aseprite
Create a copy of this sprite bypassing file data parsing by reusing the resources
Parameters:
sliceName | Name of the slice to cut from the sprite |
---|---|
spriteWidth | Width of the newly created sprite. |
spriteHeight | Height of the newly created sprite. |
useEnterFrame | Use |