I have made an app and i want to make it multi touch compatible. i have tried looking around but the answers aren’t specific to mine.
Here is what i do:
1) My coding:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
[self touchesMoved:touches withEvent:event];
if (gameState == kGameStatePaused) {(gameState = kGameStateRunning);}
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
if(gameState == kGameStateRunning) {
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:touch.view];
if(location.x > 400) {
CGPoint yLocation = CGPointMake(playerPaddle.center.x, location.y);
playerPaddle.center = yLocation;
}
if (gameStyle == kGameStyleTwoP) {
if(location.x < 100) {
CGPoint yLocation2 = CGPointMake(computerPaddle.center.x, location.y);
computerPaddle.center = yLocation2;
}
}
}
2) I have gone onto Interface Builder and checked the box for multitouch enabled
3) I build and run my app and it opens properly and when i go to test the multitouch i hold “option key” and click and move the mouse
4) (i am trying to make computerPaddle and playerPaddle both move) but only one of the works at a time
I have to tried to fix it but i can’t understand where i am going wrong.
Any help is useful.
THX.
look this line
you only take one touch and ignore rest and thats why only one thing can move
so replace with a for loop should fix the problem