Pausing a simple animation

Dave Cragg dcragg at lacscentre.co.uk
Fri May 16 03:08:01 EDT 2003


At 8:22 am +0100 16/5/03, Dave Cragg wrote:

>Your first thought was partly right -- the mouseUp handler will end
>instantly. The problem is that the animateTokens handler will run 10
>milliseconds later, and while it is running, nothing else will.
>
>I think what you need to do is remove the outer repeat loop from
>your handler, and complete each stage of the animation with another
>"send .... in x milliseconds". Then your other buttons will respond.
>
>I take it the pause button sets the b_play global to false. It might
>be a good if the "play" button sets it to true and not the animation
>handler. Then you could do something like this:
>
>local lvStage
>local b_play ### or global if needed
>
>on mouseUp
>    put true into b_play
>    put 1 into lvStage
>   send animateTokens to card "myCanvas" in 10 milliseconds
>end mouseUp
>
>on animateTokens
>   if b_play then
>     get line lvStage of field "frames"
>     ## not sure what you do with this
>
>     set the lockMoves to true
>     repeat with i = 1 to the number of images in group "tokens_group"
>       move image i of group "tokens_group" to coords without waiting
>     end repeat
>     set the lockMoves to false
>     add 1 to lvStage
>     if lvStage > the number of lines of field "frames" then
>       put false into b_play
>     end if
>     send "animateTokens" to me in 50 milliseconds ##adjust timing here
>   end if
>end animateTokens

Sorry, I wasn't too awake when I wrote that. I just realised the 
above handlers are in separate scripts, so the locals should be made 
globals, or try to put all the relevant handlers in one script (the 
card perhaps).

Cheers
Dave



More information about the use-livecode mailing list