pixi-spriter
v0.6.0
Published
Spriter animation playback engine for pixi.js.
Downloads
5
Maintainers
Readme
pixi-spriter
The pixi-spriter
library provides a simple set of classes to (hopefully) make it easy to add animations exported from Spriter Pro in your pixi.js projects!
This is currently a massive WIP - features are largely being developed in the order in which they're required for my own projects. Feel free to raise tickets for feature requests on the issues page.
Prior to v1.0.0 this repo won't use semanyic versioning as I'd like to have everythign a bit more stable before producing a v1 release. Thereafter it will adhere to semantic versioning rules :)
Features
pixi.js integration
Loading
pixi-spriter
provides a Loader Plugin for the pixi.js
resource-loader.
❌ Support for .scml
files.
✔️ Support for .scon
files.
✔️ Atlas (spritehseet) loading.
Display
✔️ Spriter entity display component.
❌ Support for Character Maps.
Playback
✔️ Play and set animations.
✔️ Smoothly blend animations.
❌ Account for animation curves.
✔️ Change playback speed.
✔️ Use negative speed values for reversed playback.
Tags
Support for checking tags of animations/components is added through a set of functions in the TagUtils
module. There aren't any convenience functions added to the display components so that if your project doesn't use the feature then the code won't be in your final bundle (assuming your bundler kaes use of tree-shaking).
The TagChecker
class provides some convenience methods and can be reused for querying different Animator
instances.
Variables
❌ TODO
Action Points
Action Points are managed by the Animator
and are interpolated like the other timeline objects (bones, and sprites). They can be retrieved (when available) through the Spriter.getPoint()
method.
Colliders
Also known as Collision Rectangles in Spriter, are also managed by the Animator
. Presently only point collisions are supported. Checking for collisions is done either calling checkCollisions
, or through the conveience method on the Spriter
class - which calls checkCollisions
internall anyway.
When calling checkCollisions
directly, the point supplied must be in the same co-ordinate space as the Animator being queried.
However, when using the Spriter
method, the point suplpied needs to be in world (global) space; the method will handle the coordinate translation internally.
Event Triggers
The Spriter
class allows for checking whether an event was triggered on the latest call to update()
. isTriggered
will only return true
for the first frame when the Event is active - even when playing animaitons at lower speeds. Spriter
also has an event: onEventTriggered
which will signal whenever an event is triggered.
const anim = new Spriter();
// Listen for events triggering.
anim.onEventTriggered.add((event) => {
console.log("Event triggered! Name:", event)
});
...
anim.update(deltaTime);
// Or check in an update loop.
if (anim.isTriggered("eventName")) {
console.log("Event triggered just now: eventName");
}
Audio Events
❌ TODO
Performance
❌ Still need to benchmark and optimise.