Help moving multiple images at once with touches
- by daveMac
Here is my problem: I am trying to move a puzzle piece around the screen and then connect to the other piece if they are in close proximity. I have achieved this, though it is perhaps a little odd the way I did. My problem though is that once they have connected, I can't figure out how to move them as one image, instead of two separate entities. I would really appreciate any help or suggestions. Here is a sample of what I have been doing:
(void)touchesMovedNSSet *)touches withEventUIEvent *)event{
UITouch *touch = [touches anyObject];
[self dispatchTouchEvent:[touch view] toPosition:[touch locationInView:self.view]];
}
-(void)dispatchTouchEventUIView *)theView toPositionCGPoint)position{
if ((CGRectContainsPoint([picture frame], position))) {
picture.center = position;
}
if (CGRectContainsPoint([picture2 frame], position)) {
picture2.center = position;
}
}