我坚持这个问题。
我在SceneKit场景上放置了一个SpriteKit节点。我试着这么做 使用SpriteKit显示标签,这些标签在触摸时切换场景。想象一下" Game Start"," Quit"," Shop"作为按钮。
但它没有用。
如何切换SceneKit中的场景与SpriteKit标签的交互?
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
}
}
答案 0 :(得分:2)
场景转换的API如下(ObjC版本):
- (void)presentScene:(SCNScene *)scene withTransition:(SKTransition *)transition incomingPointOfView:(nullable SCNNode *)pointOfView completionHandler:(nullable void (^)())completionHandler NS_AVAILABLE(10_11, 9_0);
&#34; presentScene&#34;只有一个论点并不存在。