For a little side project I'm working on a small tapper game to test out my programming skills. The only problem is that you can't identify a tap (not a beginning of a tap, or end) so you can just press down and earn points like that. Could anyone help?
Comments
@Ezekia To identify a continuous tap, when a tap begins, set a variable to true. When the tap ends, set that variable to false. Then in the draw function, if the variable is true, the tap is still happening.
Here’s what I think you’re after.
And if you want to score only one point per tap, don't score unless you've seen it go back to false. this may require another variable.
Okay, I'll give it a shot.
The
touch
object has a field calledtapCount
which might be worth experimenting with to see if that will help you. Other things that are worth considering is to say that a tap occurs if the touch ended within, say, half a second of when it started and didn't move in between starting and ending.If you want to handle multiple touches then you'll need to create a table of touches and store a copy of this data in the table for each touch. I do this in my touch handler class, but that might be overkill for your situation. In case it might be of some use, though, you can find it on github at https://github.com/loopspace/Codea-Library-Base/blob/master/Touch.lua