Game Development Community

Another Multitouch Thread (sorry)

by Joe Williams · in iTorque 2D · 03/25/2011 (11:32 am) · 7 replies

I apologize for having to post this. I know there's a thread about this somewhere, but I can't find it with the way search is now working.

Anyway, I need to track a minimum of 4 touches in my game, and I seem to remember a thread that showed code for identifying and manipulating the object under any given touch. Does anyone have the link to that thread?

#1
03/25/2011 (11:51 am)
I believe this is what you are looking for.


http://www.garagegames.com/community/forums/viewthread/125059
#2
03/25/2011 (12:22 pm)
Yeah. That thread is a great place to start. I'm still working on it, though. Which means there is no Q&A or comments until I get done. It's more than enough information to keep you occupied while I finish.
#3
03/25/2011 (12:37 pm)
That's Michael's thread about the input updates, which gives me some ideas but isn't really what I'm looking for. The thread I'm thinking of basically used the touch coordinates to call a function for whatever t2d object was under them. Michael's thread is specifically talking about gestures, like pinch to zoom. I'm just concerned with having 3 objects follow the player's fingers on one side of the screen and another follow the player's finger on the other side of the screen.
#4
03/25/2011 (12:42 pm)
try this: thread

Hope that's what you're looking for.
#5
03/25/2011 (12:57 pm)
@Joe - If you check my thread again, it's not all about gestures. I talk about the current input system, its limitations, the link to Edward Maurina's multi-touch enhancement and I link to my tutorials that show how to get world coordinates from a touch (using what is currently supported).

As for getting an object under a touch location, this is doable with the scene graph's pick point function:

function oniPhoneTouchDown( %touchCount, %touchX, %touchY )   
{ 
   // Get X value from the %touchX variable
   %xPosition = getWord(%touchX, 0);
      
   // Get Y value from the %touchY variable
   %yPosition = getWord(%touchY, 0);
      
   // Convert the touchscreen coordinates to world coordinates
   %worldPoint = sceneWindow2D.getWorldPoint(%xPosition, %yPosition);
 
   %graph = sceneWindow2D.getSceneGraph();  
   %objects = %graph.pickPoint(%worldPoint);
}

%objects will contain any t2dSceneObjects in the specified coordinates. Now, as for tracking four touch locations. Well, that's a problem since I stated in my big input thread that the current input system isn't great at handling that many touches.
#6
03/25/2011 (12:59 pm)
It helps to know what pickPoint's reference:

pickPoint(x/y,[groupMask],[layerMask],[showInvisible?],[excludeObject])

Description: Picks objects intersecting point with optional group/layer masks. For the sake of optimization, definitely use the groupMask, layerMask and excludeObject parameters.
#7
03/25/2011 (1:22 pm)
Thanks Michael. Your insight is greatly appreciated. I'm hoping the way I use touches will mean that the poor multitouch handling won't be much of a problem. It's basically a situation where I need three touches on one side of the device to control some sliders. They just go up and down, and the player can tap anywhere on the slider line to move the slider to that point.

The other side has a thumbtick. Touch handling for that will probably be susceptible to the problem you're talking about. So I'm thinking of leaving that as subject to Mouse Events, but the sliders just responding to the iPhone touch calls. Unless I'm mistaken, if the stick is the only thing set to use mouse events, then touches elsewhere won't impact it. Is that right, or am I wrong there?