Wait for animation

Somebody an idea on how to implement a method that forces other methods to wait until the current battle animation is over?


Something like:


if(this.isAnimationPlaying()){
<waitForAnimation before executing method>
}


I don't have a good idea on how to implement that, because when I try it with a while loop, the game freezes because the main game loop is interupted.


Thank you for your help.
Take a look at how Game_Interpreter does it with the show animation event command.  IIRC it turns on a flag to say there's an animation playing, and then in the update method it checks for any kind of waits (including animation) and just exits the method if there's a wait active.
Take a look at how Game_Interpreter does it with the show animation event command.  IIRC it turns on a flag to say there's an animation playing, and then in the update method it checks for any kind of waits (including animation) and just exits the method if there's a wait active.

Okay thanks I got that down ... was easier than I thought. But I  have still one problem: The Spriteset_Battle.prototype.isBusy function returns true "a litte bit too fast". How can I force the method to wait for a specific amount of frames before returning true? If that is not possible maybe it's possible to implement a "standby" phase in BattleManager where nothing happens for x frames? If that's not possible either, maybe a other solution with new flags? I tried alot with that, but nothing worked.
Thank you for your help!
I'd probably add an extra defaultWait function that decrements a variable, and returns true if the variable is greater than 0.  Call it from the isBusy function, or whatever function does all the checks to see if it's waiting for anything.  So you're just adding one more thing that could pause the action.  When you want to wait for something, just set that variable to how many frames you want to wait for.  You'll need to experiment a bit.
If all sprites in your battle is listed, then you could actually check if any of the sprites has an animation playing on it. If there's at least one sprite that has an animation still playing on it then wait. Normally you'd check it on the update method of that scene so that you could skip the other things that update has to do if there's an animation.

Original thread: https://forums.rpgmakerweb.com/threads/wait-for-animation.63177/