Jump to content

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


Cyclone112
 Share

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?

Link to comment
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();

 

Link to comment
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;

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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