检测触摸
你可以覆盖 SKScene
的 4 种方法来检测用户触摸
class GameScene: SKScene {
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
}
override func touchesMoved(touches: Set<UITouch>, withEvent event: UIEvent?) {
}
override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {
}
override func touchesCancelled(touches: Set<UITouch>?, withEvent event: UIEvent?) {
}
}
请注意,每个方法都会收到一个
touches
参数,该参数在特定情况下可以包含多个单个触摸事件。