Jump to content

Animation for only 3-4 times and then destroy it


Nitesh
 Share

Recommended Posts

I am making winning animation to play at the time when player wins.

this.mainAnimationObj.play(50, false, false);

This is playing the animation for only one time. I want to play this for 3-4 times, and after final animation, it should destroy.

I am doing like below:

private showWinnerAnimation() {
        this.mainAnimationObj.play(50, false, false);
        this.mainAnimationObj.onComplete.addOnce(this.onOneAnimationComplete, this);
}

private onOneAnimationComplete() {
        this.mainAnimationObj.play(50, false, false);
        this.mainAnimationObj.onComplete.addOnce(this.onTwoAnimationComplete, this);
}

private onTwoAnimationComplete() {
        this.mainAnimationObj.play(50, false, false);
        this.mainAnimationObj.onComplete.addOnce(this.onThreeAnimationComplete, this);
}

private onThreeAnimationComplete() {
        this.mainAnimationObj.play(50, false, true);
}

This plays animation for three times.

But the problem is that for the next game, the animation does not play at all (I think it's because the animation is not being destroyed for the first time).

Can you please help me.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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