multiple objects

Joined
Jan 13, 2011
Messages
6
Reaction score
0
Points
1
Hello everyone;
First I would like to say I am pretty new at Xcode though I have been reading and doing tutorials. I am trying to expand a little and run into a snag.
I put a background and then 4 balls a soccer ball a foot ball a volley ball and basket ball. I have them all showing up when I test in the simulater and when i tap to move one of the balls, its always the same one,,, that moves,,,
So do I need a view controller for each ball I want to move?
I am just a little stuck,, been playing all day, and I am thinking there is probably an easy way to do this,, I just do not know it yet...
Well anyways I want to thank everyone in advance.
 
OP
N
Joined
Jan 13, 2011
Messages
6
Reaction score
0
Points
1
Ok I found the answer, thanks,,, It was i a tutorial I never got to yet lol there are so many of them all over. If anyone is curious about the answer it is just an if statement for each object being touched.
 
OP
N
Joined
Jan 13, 2011
Messages
6
Reaction score
0
Points
1
hello I am relatively new to xcode and cocoa. I have been studying tutorials and reading as much as I can find online, only to discover, I ran into some questions.
I am using code 3.26 on snow leopard.
Code:
-(void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{

	

	UITouch *myTouch = [touches anyObject];

	location = [myTouch locationInView:self.view];

	

	if([myTouch view] == one) {

		

	one.center = location; 

	} else if ([myTouch view] == two) {

		two.center = location ;

	}

	

}





when I do that, nothing happens, everything shows on screen but no balls are moving.


however when I do this

Code:
-(void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{


	


	UITouch *myTouch = [touches anyObject];


	location = [myTouch locationInView:self.view];


	


	//if([myTouch view] == one) {


		


	one.center = location; 


	//} else if ([myTouch view] == two) {


	//	two.center = location ;


	//}


	


}






I can get a single ball moving, on touch,, only one though.


Any help with this would be appreciated, and I will gladly answer any questions if I havent provided enough info.
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top