views:

35

answers:

1

Suppose you have three points of contact on the iPhone screen and one of those touches moves...

The touchesMoved method will be invoked and the [[event touchesForView:self] count] will be equal to '3' because there are three touches for the event, but how can you distinguish between the touches? For example - find out whether it was the first, second, or third touch which moved?

Thanks.

A: 

the touches argument of touchesMoved:withEvent: will contain the actual touches that moved. In touchesBegan:withEvent:, you can store those away; the actual touch objects will remain the same (ie, same objects, although their values will change) throughout the entire touch sequence.

Ben Gottlieb
but touchesMoved is only passed the touches that actually move. So if there are two touches and only one moves, it only knows about one of them. It only gets passed both touches if two touches move at the same time. Even if you save the start location of all the touches in touchesBegan, when touchesMoved is called, all you have a single UITouch object (assuming only one touch moved) with its current data. So given its current locationinview, there isn't any way to identify which touch it was.
Striker
Why not store the initial touches, and compare it with them?
Ben Gottlieb