特定区域(SWIFT)触摸



我想用覆盖力触摸beban是SpriteKit。但是,只有在触摸屏幕的特定部分(F.E。图像)而不是整个屏幕时,火箭才会产生。

  override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
    let area = CGRect(x: 0, y: 0, width: 100, height: 100)
    guard let point = touches.first?.location(in: view),
          area.contains(point) else {
      return
    }
    //Spawn Logic Here
  }

最新更新