First, my touchhesBegan function, and then the structure that stores the values ββfor my object. I have an array of these objects, and I'm trying to understand when I touch the screen, if I touch an object on the screen.
I donβt know if I need to do this by repeating all my objects and figuring out if I am accessing the object this way or, perhaps, a more efficient way.
How is this usually handled?
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ [super touchesEnded:touches withEvent:event]; UITouch* touch = ([touches count] == 1 ? [touches anyObject] : nil); CGRect bounds = [self bounds]; CGPoint location = [touch locationInView:self]; location.y = bounds.size.height - location.y; float xTouched = location.x/20 - 8 + ((int)location.x % 20)/20; float yTouched = location.y/20 - 12 + ((int)location.y % 20)/20; } typedef struct object_tag
source share