Reputation: 23
I am stuck on this problem.
I laid a SpriteKit node over a SceneKit Scene. I'm trying to use SpriteKit to display labels and those labels switch scenes when touched. Imagine "Game Start", "Quit", "Shop" as buttons.
But it doesn't work.
How should I switch scenes in SceneKit from interaction with SpriteKit labels?
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
/* Called when a touch begins */
for touch: AnyObject in touches {
let location = touch.locationInNode(self)
let touchNode:SKNode = self.nodeAtPoint(location)
if(touchNode.name == "elementButton"){
//let scene = ElementsScene(size: self.size)
self.view?.presentScene(scene)
} else if (touchNode.name == "classicButton"){
//let scene = ClassicScene(size: self.size)
self.view?.presentScene(scene)
} else if (touchNode.name == "quitButton"){
//Quit Game
}
}
Upvotes: 2
Views: 734
Reputation: 4064
The API for scene transition is the following (ObjC version):
- (void)presentScene:(SCNScene *)scene withTransition:(SKTransition *)transition incomingPointOfView:(nullable SCNNode *)pointOfView completionHandler:(nullable void (^)())completionHandler NS_AVAILABLE(10_11, 9_0);
"presentScene" with just one argument doesn't exist.
Upvotes: 3