Game Development Community

Button down and up

by Adam Troutman · in General Discussion · 06/14/2006 (9:50 pm) · 2 replies

I have a function being called that spawns an object, my problem is that it spawns the item when the button is pushed down and when it is released again, I am wondering if someone can tell me how to fix this.

#1
06/14/2006 (9:59 pm)
In the function you are calling, you can have a %val parameter that is 0 or 1 if it was pulled up or pressed down. So like this.
function myKeyFunction(%val){
   if(%val){
     //do stuff
   }
}
Would make it only happen when the key is pressed down. If you put !%val, it would do it only when the key is released.
#2
06/14/2006 (10:01 pm)
Thanks, I have been wondering about this for a while.