pixijs / spine

Pixi.js plugin that enables Spine support.
Other
567 stars 217 forks source link

Play multiple animations together #178

Open Richacinas opened 7 years ago

Richacinas commented 7 years ago

Hello there,

I have been searching and testing a lot, and not being able to play, let's say, two animations together.

I read somewhere that spine-runtime is what we needed in order to manage the states and add animations from our JSON than can animate different parts at the same time, however, it is not working.

Here is some code:

`var otto = new PIXI.spine.Spine(res.otto.spineData);
otto.autoUpdate = true;
otto.state.setAnimation(0, 'speak', true);

var state2 = new spine.AnimationState(otto.stateData);
//add an animation
state2.setAnimationByName(0, 'moveHair', true);
//apply directly
state2.apply(otto.skeleton);`

What is happening is that it is not playing any of our animations at all. If we just call setAnimation with passing either of them, it does work.

This is the library we are loading so we wet that window.spine object:

https://github.com/EsotericSoftware/spine-runtimes/blob/spine-js/spine-js/spine.js

Any ideas how to play more than one animation at the same time?

Thanks a lot

ivanpopelyshev commented 7 years ago

Use different tracks. 0 is the number of track, just use 1 for second animation and it'll be ok ;)

Richacinas commented 7 years ago

Do I need to use spine runtimes at all?

ivanpopelyshev commented 7 years ago

What do you mean? pixi-spine is runtime integrated with pixi. You can look at https://github.com/pixijs/pixi-spine/tree/master/examples to understand how to use it

Richacinas commented 7 years ago

I can't find on those examples a way to add animations to different tracks.. is the first parameter of addAnimationByName the track where we want to add it?

ivanpopelyshev commented 7 years ago

yep

ivanpopelyshev commented 7 years ago
var otto = new PIXI.spine.Spine(res.otto.spineData);
otto.state.setAnimation(0, 'speak', true);
otto.state.setAnimation(1, 'moveHair', true);
Richacinas commented 7 years ago

Thanks a lot 👍 I'll test it and let you know!

It could be a problem with some of my animations exported from DragonBones... When I try speak animation alone, the mouth disappears, and I don't know why. I have to debug that and then when it works alone I'm sure that they will work together the way you say!

If you have any idea about why some sprites could disappear when you animate them, please let me know.

Cheers,

Ricardo

ivanpopelyshev commented 7 years ago

It'll be a problem, I have to dig out OLD version of pixi-spine for spine3.2, because dragonbones cant export properly.

Richacinas commented 7 years ago

I'm using the latest versions of pixi, pixi-spine and DragonBones

ivanpopelyshev commented 7 years ago

What about https://github.com/DragonBones/DragonBonesJS , does that work?

Richacinas commented 7 years ago

It was my first option, however I have no idea how to play multiple animations simultaneously using that library either...

Richacinas commented 7 years ago

It seems like the juice is here:

https://github.com/DragonBones/DragonBonesJS/issues/28

I'll try

bharathasdev commented 5 years ago

I am facing a Similar requirement for my project, I need to play 2 animations but they are exported as separate json. Can i load multiple Json(spine) on to a single pixi spine object ?. How can merge and play the animation from 2 or 3 Json ? any pointers or help is much appreciated. Thanks in advance @ivanpopelyshev popelyshev please help

ivanpopelyshev commented 5 years ago

@bharathasdev I know that its possible and its not that difficult if you read how AnimationState and animation json data are created. How much time did you spent on it? I'm currently very limited in my words because of vacation :)

Something like "I've spent 3 hours and understood X Y Z but so far no answer for playing multiple animations", then I'll look into it.

bharathasdev commented 5 years ago

Hi Ivan Popelyshev,

Thank you vvery much for replying during your vactaion.

I am new to Pixi and new to Spine. I have spent couple of hours but that for letting me it is achievable. I will dig deeper to make ti work.

I was confused whether it is achievable or do i need to ask graphic artist to expost all the animations into one json. I will start exploring more.

Thanks,

On Wed, May 1, 2019 at 3:14 PM Ivan Popelyshev notifications@github.com wrote:

@bharathasdev https://github.com/bharathasdev I know that its possible and its not that difficult if you read how AnimationState and animation json data are created. How many times did you spent on it? I'm currently very limited in my words because of vacation :)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/pixijs/pixi-spine/issues/178#issuecomment-488293387, or mute the thread https://github.com/notifications/unsubscribe-auth/AAPR6AHSWE435KZMBLNYOGLPTGQUBANCNFSM4DP5YVQQ .