How to check if specific animation is active and running?
Janne

Hi,
how to check onUpdate if sceneobject has specific animation running at the moment or not?

And is there any possibility to run animation ( example onKeyDown: this.playAnimation("swingSword")) only one time,
and after that animation ends, change to another animation automatically active?

Thanks!

All 2 Comments
Gio

Hi Janne

To check if a specific animation is playing, you could do something like this

if (_.myObject.getSprite().getCurrentAnimationName() == 'myAnimation')
{
    // do something here
}

If you want to play a specific animation after another one finishes, for example you want to play a 'dance' animation once your 'swingSword' animation is over, you can do this:

_.myObject.playAnimation('swordSwing');

_.myObject.onAnimationEnd = function()
{
    this.playAnimation('dance');
    this.onAnimationEnd = null;
};

 

Janne

That works! Thank you :)

Post a reply
Add Attachment
Submit Reply
Login to Reply