Kiểm tra SceneKitVehicle bản demo của Apple. Ai đó vui lòng ported it to Swift.
Mã bạn muốn có trong tệp GameView.swift. Trong GameView bạn sẽ thấy ghi đè touchesBegan. Đây là phiên bản của tôi cho 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")
}
}
Nếu không rõ; GameView được đặt làm lớp xem của ứng dụng theo cách của Bảng phân cảnh.
Nguồn
2015-10-15 15:49:14
một số chi tiết khác – user3138007