Xavier
Xavier

Reputation: 9079

How do I keep track of two fingers independently?

I want to implement first person controls for an iOS game. Left thumb will be used for moving the character using a virtual analog stick and the right thumb for moving the characters view point around. I have the right thumb part down using touchesBegan, touchesMoves, and touchesEnded in my UIView. But I can't wrap my head around how I keep track of when both the left and right thumb are down. Is there a way I can keep track of the finger that drove the Began, Moves, and Ended callbacks? If not how am I supposed to do this?

Upvotes: 1

Views: 417

Answers (1)

jbat100
jbat100

Reputation: 16827

As the two fingers move, the UITouch objects passed as a set to the touchesBegan, touchesMoves, and touchesEnded callbacks are the same two objects in memory (same memory address). You can differentiate between the two fingers just by comparing the memory addresses of the UITouch objects.

Upvotes: 4

Related Questions