Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 02-24-2010, 08:54 PM   #1 (permalink)
Whitehk
Registered Member
 
Whitehk's Avatar
 
Join Date: Feb 2010
Posts: 119
Whitehk is on a distinguished road
Default Handle multiple touches without interfering with one another?

Hi. You might have seen my previous thread. If not, I am trying to create a multiplayer pong-like game (the 2 player-same device option on the glow hockey app would be a great example of what I'm trying to create only in the form of pong) and I need to figure out how to detect multiple touches without interfering with one another (or you can go to this link: http://www.iphonedevsdk.com/forum/ip...tyle-game.html). I don't want player 1 to have to lift there finger in order for player 2 to be able to move their paddle. I want them to be completely separate touches. This is what I have so far:

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent*)event {
UITouch *touchPlayer1 = [[event allTouches] anyObject];
UITouch *touchPlayer2 = [[event allTouches] anyObject];
CGPoint locationOfPlayer1 = [touchPlayer1 locationInView:touchPlayer1.view];
CGPoint locationOfPlayer2 = [touchPlayer2 locationInView:touchPlayer2.view];
CGPoint xPlayer1Location = CGPointMake(locationOfPlayer1.x,player1.center.y);
CGPoint xPlayer2Location = CGPointMake(locationOfPlayer2.x,player2.center.y);
if(locationOfPlayer1.y > 240) {
player1.center = xPlayer1Location;
}
if(locationOfPlayer2.y < 240) {
player2Multiplayer.center = xPlayer2Location;
}
}
Whitehk is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 175,526
Threads: 94,046
Posts: 402,624
Top Poster: BrianSlick (7,978)
Welcome to our newest member, iThoms
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 09:19 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.