在我当前的ios项目中,我将屏幕的一侧分配给一个对象,屏幕的另一侧分配给另一个对象,并且我做到了这样,如果您将手指划过指定对象上屏幕的一侧会移动。但是,我想让它能够在不同的运动中同时移动两个物体,但我无法弄清楚如何去做。以下是我目前的代码。同时移动2个对象
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:touch.view];
if (location.x <= 270) {
[Person setCenter:CGPointMake(location.x, Person.center.y)];
}
else {
[Person1 setCenter:CGPointMake(location.x, Person1.center.y)];
}
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:touch.view];
if (location.x <= 270) {
[Person setCenter:CGPointMake(location.x, Person.center.y)];
}
else {
[Person1 setCenter:CGPointMake(location.x, Person1.center.y)];
}
}
我面对同样的问题与此代码,因为我用我的原始代码。我试图重写我的方法来编写我的机制,但我不能完全弄清楚如何让对象同时移动,谢谢您的输入,但是 – user3795419 2014-09-30 00:18:02
@ user3795419所以当您开始进行多点触摸时发生了什么?你能形容吗?代码应该工作......谢谢 – DaTa 2014-09-30 01:23:46
我只能一次移动其中一个对象。当我尝试通过在指定区域上滑动手指同时移动两个对象时,只有其中一个移动了 – user3795419 2014-09-30 03:31:53