Help moving multiple images at once with touches
Posted
by daveMac
on Stack Overflow
See other posts from Stack Overflow
or by daveMac
Published on 2010-04-30T16:05:14Z
Indexed on
2010/04/30
16:07 UTC
Read the original article
Hit count: 147
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; } }
© Stack Overflow or respective owner