Page 1 of 1

PlayAnim Sync

Posted: Fri Mar 27, 2015 10:21 pm
by djrikki
Please can someone give me an example of how to open an animation in a display, but crutially allow the user to stop the animation if they press the ESC key.

I've been playing with the Async attribute of the PlayAnim function, but with little success. Naturally I tried IsAnimPlaying() first, but accordingly to the documentation that command has been made obselete some time - it would have been ideal to use that along with IsKeyDown.

Re: PlayAnim Sync

Posted: Sat Mar 28, 2015 12:01 pm
by airsoftsoftwair
PlayAnim() was designed to play anims synchronously, i.e. without returning control to your script. There are two ways to have an anim playing without getting your script blocked:

1) Set the "Async" tag to TRUE and then call AsyncDrawFrame() to skip to the next frame.

2) Enable layers and use NextFrame() to display the next frame. In that case, you must not use PlayAnim() but DisplayAnimFrame() so that a layer of type #ANIM is added.

Both solutions boil down to the same point, though: In both cases you'll have to manually call a function that will display the next anim frame. It's not really convenient but that's the way the anim API was designed :)