deangiberson / spriter-scon-js

A simple JS based animation playback engine for Spriter SCON files.
MIT License
11 stars 0 forks source link

Pivots in keyframes #1

Open felipemanga opened 8 years ago

felipemanga commented 8 years ago

Hello, I'm not sure if this lib's still being maintained, but it is of use to me and might be to others, so I'd like to document this here. I had some trouble with one of my animations, and the following seams to fix it:

in unmapFromParent, I added to the "s" object (after line 114): pivot_x : pos.pivot_x, pivot_y : pos.pivot_y,

in the tween function (line 137), do not default to 0: pivot_x : lerp( ao.pivot_x, bo.pivot_x, t), pivot_y : lerp( ao.pivot_y, bo.pivot_y, t),

Now, your draw callback can do the following: if( !isNaN(obj.pivot_x) ) sprite.anchor.x = obj.pivot_x; else sprite.anchor.x = file.pivot_x; if( !isNaN(obj.pivot_y ) ) sprite.anchor.y = obj.pivot_y; else sprite.anchor.y = file.pivot_y;

deangiberson commented 8 years ago

Thanks Felipe, I'm not maintaining this any more the Spriter team has developed a much more complete JS runtime. I'll take a look a this change next week, unless you have a pull request available.

felipemanga commented 8 years ago

The official implementation has a bigger footprint compared to yours (requires goog.js, totalling 177KB vs just 8KB for this), and I got this working much more quickly. When all I need is to play back some simple animations, this is a much nicer solution.