Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pivots in keyframes #1

Open
felipemanga opened this issue Feb 25, 2016 · 2 comments
Open

Pivots in keyframes #1

felipemanga opened this issue Feb 25, 2016 · 2 comments

Comments

@felipemanga
Copy link

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
Copy link
Owner

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
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants