5
SceneKit scene
ile UIViewController
içine bir oyun oluşturdum.SpriteKit için UITapGestureRecognizer öğesinin dokunma konumunu çevirin - Swift
// TAP GESTURE
let tapGesture = UITapGestureRecognizer(target: self, action: "handleTap:")
sceneView.overlaySKScene?.view!.addGestureRecognizer(tapGesture)
Ve handleTap
işlevi:
func handleTap(sender: UIGestureRecognizer) {
if sender.state == UIGestureRecognizerState.Ended {
var touchLocation = sender.locationInView(sender.view)
touchLocation = self.view.convertPoint(touchLocation, toView: self.view)
let touchedNode = sceneView.overlaySKScene?.nodeAtPoint(touchLocation)
if touchedNode == myNode {
// DO SOMETHING
}
}
}
myNode
'ın pozisyonu
(x: 150.0, y: 150.0)
olduğunu düşünün
Ben böyle
UITapGestureRecognizer
uyguladı. Sorun,
touchPosition.y
'un
myNode
y konumunun y konumunun tersinde olmasıdır.
Dokunuşun konumunu nasıl tersine çevirebilirim?
Teşekkürler!
Nerede convertPointFromView uygulanmasıdır? –
bu geçersiz kılma, UIviewcontroller sınıfımda didMovetoView yöntemini çağırmıyor. niye ya? – Hitesh