Game Development Community

Getting Gestures to Work with Touches

by John Vanderbeck · in iTorque 2D · 05/24/2012 (7:17 am) · 4 replies

So over the last few days I managed to get standard iOS GestureRecognizers working in my iT2D build. It isn't well integrated yet, but is more in a test state.

However the problem I've run into it trying to integrate gesture recognition and standard touches together. Essentially the interfere with each other, more or less depending on how I set things up.

I could roll my own algorithms for the gestures, but i'd much rather use the internal iOS ones so that the user gets the exact same gestural support that they are used to elsewhere in the OS.

Has anyone used things like Swipe and Pan gestures in addition to the standard iT2D touch methods?

#1
05/24/2012 (7:55 am)
Hi John;

My suggestion to you would be that, since you have made the effort to integrate certain UIGestureRecognizer handlers in your code base, you should just complete the integration and override/bypass/kill the default Touches code altogether.

I'm currently using a heavily-modified version 1.4.1 of iT2D, so I'm not sure if your code base is any different. However, the touchesBegan/Ended/etc code resides in iPhoneOGLVideo.mm for me.

Since there already exists an UITapGestureRecognizer for you to utilize, get rid of the old stuff (unless, of course, you are still wanting to support pre-3.2 devices, in which case you'd need both around).

Good luck!
#2
05/24/2012 (6:49 pm)
How would you replace touchesMoved with just gestures? I don't think I can remove the standard touches completely.
#3
05/25/2012 (7:06 am)
So I realized I could do it with the pan gesture, once I realized there was a locationInView method I could use to get the absolute coords.

I think there may be a bug with retina though in coordinates and view sizes. Not positive, but the coordinates returned from the gesture are weird.

There is no 0,0 anywhere in the view according to the gesture. According to the gesture the coordinates in view space run from x0 to x1024 (this is in landscape mode), but the y runs from y768 to y1536 rather than 0 to 768. Odd. This is the OGL's view.
#4
05/25/2012 (7:09 am)
Ignore my previous issue. I was forgetting to convert the point to retina space.

oops.