Jump to content

PIXI Spine animations on events.


Danisimo
 Share

Recommended Posts

Hello everyone. 
I'm using spine animations in a project that I'm working on. As advised on the forums, I've turned autoUpdate off and have implemented manual updates for the spines. They are collected in an array as soon as they are created and are updated on each game tick. This approach has solved a lot of issues however a very strange corner case has come up. 
I have two spine animations. I want to play the second one when an event from the first one fires. I listen for the event on the first animation and start the second animation inside the callback. This however causes the second animation to render incorrectly on the first frame it's created and but continues to play its animation normally. What happens is that the spine object appears incorrectly positioned and flipped for just one frame. The frame it's created on, then on the next tick it gets updated and animates and renders normally. 
This does NOT happen if I manually call the update method on the spine animation on the tick I create it and it does not happen with autoUpdate enabled.
I'm going to try and create an example to show this behavior I just wanted to make a post and ask in case it's something very obvious that I might be missing.

Link to comment
Share on other sites

I want to play the second one when an event from the first one fires
 

autoUpdate is a hacky thing that works inside updateTransform(), because pixi doesnt have dedicated methods for animations, thus, creating a race condition.

Its supposed to work like that. There was PR for dedicated animations: https://github.com/pixijs/pixijs/pull/4586 , but other members of team didnt understand why i made it.

If you have multiple projects, I can make that PR and you'll back it like "ho-ho-ho BIG COMPANY NAME needs this thing" , and then it'll be merged. Can you do that? :)

Link to comment
Share on other sites

I see. So adding/removing spine animations on events causes issues with updateTransform? I hadn't noticed this until now as this isn't a common use case. I'll see if I can offer your PR some support. :D 
The strange thing is. As per your advice on older threads I removed autoUpdate and implemented it as manual updates. Now each spine animation's update method is called on each game tick inside a custom Ticker class. This approach causes issues with adding spine animations on events but reverting to the default autoUpdate fixes it. This is what puzzles me the most.

Edited by Danisimo
Link to comment
Share on other sites

This approach causes issues with adding spine animations on events but reverting to the default autoUpdate fixes it. This is what puzzles me the most.

well, you modify an array when you go through it. it might cause problems, if you save length of array before the for, there are many behaviours

Edited by ivan.popelyshev
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...