Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

fox10078

macrumors 6502
Original poster
Nov 6, 2009
467
86
Hello, this is the code im using currently to move my ship along an X-axis, right now it responds to any touch on the screen and automatically centers on the Y-axis of were the touch is located. Now I want it to only respond to touches on the ship, how would I do this?

Code:
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { 
	UITouch *touch = [[event allTouches] anyObject];
	CGPoint location = [touch locationInView:touch.view];
	CGPoint xLocation = CGPointMake (location.x,ship.center.y);
	ship.center = xLocation;
	info.text = nil;
	
}
 
What exactly is the ship object?

If it's a basic UIImageView or something, you can just subclass it and put the touches code in that.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.