Cyclone112

How to pause an animation, play a different one and then resume the original one

Recommended Posts

So I have 2 animations that both work independently. I can pause and unpause either of them fine but I can't pause one, play the other and then unpause the first.

Quote

this.animations.play("animation1", 10);

// Sometime later

this.animations.getAnimation("animation1").paused = true;

// Sometime later

this.animations.getAnimation("animation1").paused = false;

 

This doesn't and no animations play in the end

Quote

this.animations.play("animation1", 10);

// Sometime later

this.animations.getAnimation("animation1").paused = true;

this.animations.play("animation2", 10);

// Sometime later

this.animations.getAnimation("animation2").paused = true;

this.animations.getAnimation("animation1").paused = false;

 

Any ideas?

Share this post


Link to post
Share on other sites

Try 

var anim1 = this.animations.getAnimation("animation1");
var anim2 = this.animations.getAnimation("animation2");

this.animations.play("animation1", 10);

// Sometime later

anim1.paused = true;
anim2.play();

// Sometime later

anim2.paused = true;
anim1.play();

 

Share this post


Link to post
Share on other sites

Okay I finally got it working. You need to reset the currentAnim object on the animation manager back to anim1 after pausing anim2 and it starts right where it left off.

var anim1 = this.animations.getAnimation("animation1");
var anim2 = this.animations.getAnimation("animation2");

this.animations.play("animation1", 10);

// Sometime later
anim1.paused = true;
this.animations.play("animation2", 10);

// Sometime later
anim2.paused = true;
this.animations.currentAnim = anim1;
anim1.paused = false;

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.