开发者

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) {
   开发者_如何学Python      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?


Did you set UIView's multipleTouchEnabled to YES?


multipleTouchEnabled should be set to YES for the UIView.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜