Quote:
Originally Posted by Whitehk
The only problem with this is that both user's touches interfere with one another. I want to make it to where it does what you said, but Player 1 and Player 2 are able to move their paddles separately and at the same time. If I did it like you said, Player 1 would have to start the game, hit the ball, then release his finger in order for player 2 to be able to move their paddle. I do appreciate the reply though. It was definitely on the right track. Now, I just need to figure out how to make two separate touches on each half of the court. Anyone got any ideas?
|
Maybe You Can try this:
CGPoint touchPoint = [touch locationInView:self.view];
CGPoint location = [touch locationInView:touch.view];
//if (CGRectContainsPoint([paddle frame], touchPoint)) {
if (location.y >= 241){
[UIView beginAnimations:@"Move Paddle" context:nil];
CGPoint xtouchPoint = CGPointMake(touchPoint.x,paddle.center.y);
paddle.center = xtouchPoint;
[UIView commitAnimations];
}
//if (CGRectContainsPoint([paddle2 frame], touchPoint)) {
if (location.y <= 240){
[UIView beginAnimations:@"Move Paddle" context:nil];
CGPoint xtouchPoint = CGPointMake(touchPoint.x,paddle2.center.y);
paddle2.center = xtouchPoint;
[UIView commitAnimations];
}
}
}
thats the code i used,
I Have a game similar to what you are trying to do in the App Store it's called "Star Tennis"
Hope this helps