Flixel-animate is a HaxeFlixel library meant to load texture atlases generated both from Adobe Animate and the BetterTextureAtlas plugin. The library is heavily inspired by FlxAnimate, though with some differences to work similarly to the Flash/Animate JSFL implementation.
Important
flixel-animate, by default, uses a bounds method that acts similarly to how a normal Sparrow flixel sprite would load.
This "flixel accurate" bounds come with more accurate support for functions that require width and height values like updateHitbox and centerOrigin, which give closer parity with FlxSprite.
If you are migrating from FlxAnimate these bounds may be different to FlxAnimate's ones.
This offset can be activated through enabling the applyStageMatrix. Which will also apply the stage matrix of the Texture Atlas, if it was exported from an symbol instance.
To create a sprite with a loaded texture atlas, create an FlxAnimate sprite object.
The class FlxAnimate is meant as a replacement to FlxSprite, its capable of loading both
normal atlases (such as Sparrow) and Adobe Animate texture atlases.
Here's a small sample:
import animate.FlxAnimate;
import animate.FlxAnimateFrames;
var sprite:FlxAnimate = new FlxAnimate();
sprite.frames = FlxAnimateFrames.fromAnimate('path/to/atlas');
add(sprite);
sprite.anim.addByTimeline("main animation", sprite.library.timeline);
sprite.anim.play("main animation");Note that sprite.anim is the same object as sprite.animation!
You can use any of them, at your own choice, they both will play both texture atlas and normal flixel animations.
sprite.anim only exists for type safety so you can access extra functions like addByTimeline and such.
Here's a list of all the ways to add animations when using an Adobe Animate texture atlas.
sprite.anim.addBySymbol("symbolAnim", "symbolName");
sprite.anim.addBySymbolIndices("symbolAnim", "symbolName", [0, 1, 2, 3]);
sprite.anim.addByTimeline("tlAnim", someTimelineObject);
sprite.anim.addByTimelineIndices("tlIndicesAnim", someTimelineObject, [0, 1, 2, 3]);
sprite.anim.addByFrameLabel("labelAnim", "frameLabelName");
sprite.anim.addByFrameLabelIndices("labelIndicesAnim", "frameLabelName", [0, 1, 2, 3])When first loading a texture atlas, there are some settings available to change several factors about how the texture atlas will be rendered and cached. For more information check the docs.
Here's a small sample of how to use the currently available settings:
var frames = FlxAnimateFrames.fromAnimate('path/to/atlas', {
swfMode: false, // If to render like in a SWF file, rather than the Animate editor.
cacheOnLoad: false, // If to precache all animation filters and masks at once, rather than at runtime.
filterQuality: MEDIUM // Level of quality used to render filters. (HIGH, MEDIUM, LOW, RUDY)
onSymbolCreate: SymbolItem->Void // Function called when a symbol item is created, useful for hardcoded modifications.
});To install flixel-animate, there are two ways to obtain it:
-
Haxelib Installation: This provides the latest stable version offlixel-animate.haxelib install flixel-animate
-
Haxelib Git Installation: This provides the latest version offlixel-animatefrom the Repository.haxelib git flixel-animate https://github.com/MaybeMaru/flixel-animate.git
Once you have flixel-animate installed, you'll need to add it to your project to use.
You will need to add the following code to your project.xml file:
<haxelib name="flixel-animate" />