Button help
Moderators: Shine, Insert_witty_name
Button help
Ok, I have the code to see when you press a button. But I only want it to go through the code for the button press once while its held down. now it does it every time it goes through the main loop. Is there a way to tell when its lifted so it will only work when they lift the button?
Re: Button help
You could set a variable when it is pressed, and then keep your loop going while that variable is true, until thejivemasta wrote:Ok, I have the code to see when you press a button. But I only want it to go through the code for the button press once while its held down. now it does it every time it goes through the main loop. Is there a way to tell when its lifted so it will only work when they lift the button?
crossdetected = true
ispressed = true
while ispressed
pad.read()
if pad:cross()
crossdetected = true
else
if crossdetected
crossdetected is false
endif
endif
wend
But I think there was another way, something like pad:_cross(), the underscore indicating that there was a release. You should look at the example Shine gave in my thread on button presses, as that one distinguishes between presses and releases.