Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 通过触摸帮助一次移动多个图像_Objective C_Iphone_Cocoa Touch - Fatal编程技术网

Objective c 通过触摸帮助一次移动多个图像

Objective c 通过触摸帮助一次移动多个图像,objective-c,iphone,cocoa-touch,Objective C,Iphone,Cocoa Touch,这是我的问题:我试图在屏幕上移动一个拼图块,然后连接到另一个拼图块,如果它们非常接近的话。我已经做到了这一点,尽管我这样做可能有点奇怪。但我的问题是,一旦它们连接起来,我就不知道如何将它们作为一个图像而不是两个单独的实体移动。我真的非常感谢任何帮助或建议。以下是我一直在做的一个示例: - (void)touchesMovedNSSet *)touches withEventUIEvent *)event{ UITouch *touch = [touches anyObject]; [self

这是我的问题:我试图在屏幕上移动一个拼图块,然后连接到另一个拼图块,如果它们非常接近的话。我已经做到了这一点,尽管我这样做可能有点奇怪。但我的问题是,一旦它们连接起来,我就不知道如何将它们作为一个图像而不是两个单独的实体移动。我真的非常感谢任何帮助或建议。以下是我一直在做的一个示例:

- (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;
}
}

一旦他们连接,您是否允许他们再次断开连接?如果没有,我只会销毁两个原始片段,并用一个显示合并图像的对象替换它们。这种方法的一个有益的副作用是,随着用户离完成拼图越来越近,对象的数量会随着时间的推移而减少。

您还可以做的是设置一个数组,将各个块连接起来,当选择其中一个块时,您知道现在要同时移动两个部件或所有连接的部件