Esaminare SceneKitVehicle demo di Apple. Qualcuno gentilmente ported it to Swift.
Il codice che si desidera è nel file GameView.swift. Nella GameView vedrai i tocchi. Override iniziale. Ecco la mia versione di esso per la Swift 2.1:
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
guard let scene = self.overlaySKScene else {
return
}
let touch = touches.first!
let viewTouchLocation = touch.locationInView(self)
let sceneTouchPoint = scene .convertPointFromView(viewTouchLocation)
let touchedNode = scene.nodeAtPoint(sceneTouchPoint)
if (touchedNode.name == "Play") {
print("play")
}
}
Se non è chiaro; GameView è impostato come classe di visualizzazione dell'app tramite lo Storyboard.
fonte
2015-10-15 15:49:14
altro dettaglio – user3138007