I created a game with a SceneKit scene in a UIViewController .
I implemented a UITapGestureRecognizer as follows:
// TAP GESTURE let tapGesture = UITapGestureRecognizer(target: self, action: "handleTap:") sceneView.overlaySKScene?.view!.addGestureRecognizer(tapGesture)
And the handleTap function:
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 {
Suppose the position is myNode (x: 150.0, y: 150.0) . The problem is that touchPosition.y is in the opposite y position of myNode y.
How can i invert y by touch?
Thanks!
source share