Hi,
I’m assuming I’d have to write a touch screen swipe input?
Such as up, down, left & right?
Thanks,
David
Hi,
I’m assuming I’d have to write a touch screen swipe input?
Such as up, down, left & right?
Thanks,
David
Yes, there’s no built in support for gestures. If you keep track of action.pressed, action.released, direction, distance and time then that should be enough to determine if the gesture was a swipe and if so in what direction. I’m sure there are some guidelines on the threshold values to distinguish between a fling, swipe and a drag.
OK, thanks. I’ll give it a go.
How do you go about accessing time?
I figured out how to get difference of action.pressed(action.y) and action.released(action.y) and used that as telling me if character moves up or down, but how do I know how long the touch was held?
You can use os.time() for time stamp in full seconds or socket.gettime() for millisecond precision.
Thank you. I’d found os.time(), it wasn’t a good fit as swipes are less than a second.
Will use socket.gettime() and see how that works.
New to LUA also.
I managed to do mine based on this Java script: http://www.javascriptkit.com/javatutors/touchevents2.shtml
Obviously, it’s up to you, but I think you need to add a timer. If it takes 10 seconds to swipe 50 pixels, I don’t think that counts as a swipe.
Yes, you right. Thanks.
I made changes to gist.