Multi Touch

Member
Posts: 94
Joined: 2008.08
Post: #1
I'm trying properly handle multi touches. I'm using touchesBegan, touchesMoved etc and I've run into the following scenario:

I get an event for touch A
Then an event for touch B

Then, I can track if a touch has been moved, but I dont know whether it was A or B that was moved. Any ideas on how to solve this?

Thanks
Quote this message in a reply
Member
Posts: 249
Joined: 2008.10
Post: #2
wonza Wrote:I'm trying properly handle multi touches. I'm using touchesBegan, touchesMoved etc and I've run into the following scenario:

I get an event for touch A
Then an event for touch B

Then, I can track if a touch has been moved, but I dont know whether it was A or B that was moved. Any ideas on how to solve this?

Thanks

Firstly you must activate it.
Quote this message in a reply
Member
Posts: 94
Joined: 2008.08
Post: #3
Sorry, I should have mentioned I have activated it. I'm just wondering how u track between touches, it says something I'm the docs about copying the status of each touch object but I'm not sure what that means and how I would use it to know which touch is which.

Thanks!
Quote this message in a reply
Member
Posts: 440
Joined: 2002.09
Post: #4
wonza Wrote:Sorry, I should have mentioned I have activated it. I'm just wondering how u track between touches, it says something I'm the docs about copying the status of each touch object but I'm not sure what that means and how I would use it to know which touch is which.
Although it's not clear at all in the documentation, each touch object is persistent from "began" to "end/cancelled". So you can save a pointer to each touch object or use their hashes to identify them in the next callback.
Quote this message in a reply
Member
Posts: 34
Joined: 2009.01
Post: #5
Frank C. Wrote:Although it's not clear at all in the documentation, each touch object is persistent from "began" to "end/cancelled". So you can save a pointer to each touch object or use their hashes to identify them in the next callback.
Thanks for pointing this out. I just re-read the UITouch class documentation, and you're right -- it's not plainly obvious. In fact, it's kind of buried in a single sentence in the overview.

Just be sure that if you do "save a pointer" to a UITouch instance, you're not retaining it. In that same overview section, the docs say you should never do that.
Quote this message in a reply
Member
Posts: 94
Joined: 2008.08
Post: #6
dont suppose you have a little sample code for me? I need spoon feeding sometimes Blush mainly because Im still not that used to C yet.
Quote this message in a reply
Member
Posts: 440
Joined: 2002.09
Post: #7
wonza Wrote:dont suppose you have a little sample code for me? I need spoon feeding sometimes Blush mainly because Im still not that used to C yet.

Well you'll need to brush up on your Obj-C if you want to get anywhere with the SDK but basically when you get your UITouch objects in touchesBegan you'd stick the hashes into some variable/class/structure you can access later - e.g.:
Code:
myhash = [touch hash];
Then in touchesMoved/Ended you compare your saved hashes with the new touches and do whatever you need to do:
Code:
if (myhash == [touch hash]) { // Same touch, so do stuff }
Quote this message in a reply
Member
Posts: 94
Joined: 2008.08
Post: #8
Thanks, thats exactly what I was after!

yeah, I really need to learn more about Obj-C, Im just picking it up as I go along really
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Enable Multi-Touch? MrPenguin9 4 3,655 Mar 14, 2010 12:55 PM
Last Post: MrPenguin9
  Multi-touch failing Sumaleth 1 2,494 Feb 24, 2010 08:49 PM
Last Post: Sumaleth
  Multi touch individual fingers jjslay 3 3,149 Jun 18, 2009 10:01 AM
Last Post: jjslay
  Multi touch response time captainfreedom 12 6,980 May 9, 2009 12:35 PM
Last Post: Frank C.
  Input performance with multi touch godexsoft 6 3,409 Jan 17, 2009 12:04 AM
Last Post: longjumper