使用Swift / SKScene检测触摸

时间:2017-06-06 21:05:15

标签: ios swift sprite-kit skspritenode skscene

我正试图弄清楚如何使用SKScene的子类检测屏幕上任何位置的触摸,以便我可以转换。我该怎么做?

由于

1 个答案:

答案 0 :(得分:0)

       override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {

      let location = touch.location(in: self)


      print(location)

     //if your touch location = a button or anything it transitions to a new scene 
       if location = //Startbutton {
       let transition = SKTransition.reveal(with: .down, duration: 0.75)
     let gameScene = GameScene(size: size)
     gameScene.scaleMode = scaleMode
     view?.presentScene(gameScene, transition: transition)

打印用户触摸位置...希望有点帮助m8