Can't tap SKSpriteNode - no touch detected ios

后端 未结 4 570
萌比男神i
萌比男神i 2021-01-12 08:49

I am pretty new to iOS, objective C and working with Xcode. I only did one simple news type app, but now I would like to create a game I had published on another platform.

4条回答
  •  鱼传尺愫
    2021-01-12 09:21

    In Swift 2.0!

    override func touchesBegan(touches: Set, withEvent event: UIEvent?) {
    
      let touch = touches.first!
      let location = touch.locationInNode(self)
      let node = self.nodeAtPoint(location)
    
      if node.name == "spriteName" {
        // Present new game scene
      }
    }
    

提交回复
热议问题