How do I prevent a Key being pressed down all the time?

Eric Chatonet eric.chatonet at sosmartsoftware.com
Sat Sep 27 11:04:18 EDT 2008


Bonjour WIlliam,

Obviously your son has found an easy way to win :-)
All key events are sent repeatedly as long as the key is pressed.
To prevent further triggering by the same handler, just use the  
flushEvents function to trash all events you don't want until your  
handler has been effectively completed.
See FlushEvents in the docs and have a nice race :-)

Le 27 sept. 08 à 13:32, William de Smet a écrit :

> Hello all,
>
> For my little son (4 years of age) I am making a little car game in
> which he can move a car around the screen using the arrowkeys.
> I made a few obstakels (walls) so he has to move around them but when
> he hits them he is send back to the beginposition.
> Not to difficult for me to make :-)  and a lot of joy for him!!
>
> But now I found a 'bug' in my own game :-(
> When you keep the arrowkeys pressed down (instead of just one press)
> and hits an obstakel there is now hit and he is not send back to the
> beginposition.
> How do I prevent this?
>
> I use the following:
> if theKeyNumber is 65363 --rechts
> then move img "dummy" relative 30,0
>
> if intersect (img "dummy", grc "muur")
> then send mouseup to btn "start" -- btn start send the car beck to its
> beginposition
>
> Thanks!
>
> William

Best regards from Paris,
Eric Chatonet.
----------------------------------------------------------------
Plugins and tutorials for Revolution: http://www.sosmartsoftware.com/
Email: eric.chatonet at sosmartsoftware.com/
----------------------------------------------------------------





More information about the use-livecode mailing list