相关疑难解决方法(0)

iOS - 拖放碰撞检测如何检测所选项目何时拖动到另一个子视图?

我们正在添加拖放功能,以便成为一个有球员位置的运动场.

使用Interface Builder映射出位置,每个位置都是一个单独的UIImageView.

我们希望能够将玩家图像从屏幕一侧的工作台位置拖动到场地上的位置.

我们如何最好地检测被移动的所选玩家何时与现有的gamePosition imageView碰撞?

我们正在寻找一种方法来检测当前位置下是否存在视图或ImageView.

-(void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
  UITouch *touch = [[event allTouches] anyObject];
  CGPoint location = [touch locationInView:touch.view];
  tile1.center = location;  

  if gamePositionExistsAtCurrentLocation(location) { //want something like this
    [tile1 setBackgroundColor:[UIColor blueColor]]; 
  } else {
   [tile1 setBackgroundColor:[UIColor yellowColor]]; 
  }
}
Run Code Online (Sandbox Code Playgroud)

iphone drag-and-drop collision-detection ios

8
推荐指数
1
解决办法
6511
查看次数

标签 统计

collision-detection ×1

drag-and-drop ×1

ios ×1

iphone ×1