【问题标题】:touchesBegan in specific area(Swift)touchesBegin in specific area (Swift)
【发布时间】:2017-12-23 21:08:12
【问题描述】:

我想用 覆盖 func touchesbegan 是 spritekit。 但是火箭只会在触摸屏幕的特定部分(例如图像)时才会生成,而不是整个屏幕。

【问题讨论】:

    标签: swift touchesbegan


    【解决方案1】:
      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
      }
    

    【讨论】:

      猜你喜欢
      • 2022-12-02
      • 2021-05-14
      • 1970-01-01
      • 2022-12-27
      • 2022-12-01
      • 2022-12-01
      • 2022-12-02
      • 2022-12-02
      • 2015-09-26
      相关资源
      最近更新 更多