Preston
Preston

Reputation: 1059

TouchesMoved With 2 Fingers

I am trying to make a simple landscape "split screen" app where two players can play at once (each player gets one half of the screen), but I am having trouble tracking both touches at the same time. This is the code I am trying to use:

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    for (UITouch *touch in touches) {
         CGPoint point = [touch locationInView:self.view];
         if (point.x < 240) {
             [player1 updatePoint:point];
         } else {
             [player2 updatePoint:point];
         }
     }
 }

But I am obviously doing something wrong. Although this code works fine, it will only track one finger and move the player on the side of the screen the finger is on. What is my code lacking? Is this task more difficult to pull off then I think it is?

Upvotes: 1

Views: 427

Answers (2)

Ravi
Ravi

Reputation: 8309

multipleTouchEnabled should be set to YES for the UIView.

Upvotes: 0

Jano
Jano

Reputation: 63667

Did you set UIView's multipleTouchEnabled to YES?

Upvotes: 3

Related Questions