所以我想在游乐场制作一个SceneKit项目,但现在我正在努力进行场景转换。问题是我想在按下任何键盘时进行场景更改,但不知道如何将键盘作为输入。 这就是我试过的:
import Cocoa
import SceneKit
import PlaygroundSupport
let viewer: SCNView!
let frame = CGRect(x: 0, y:0, width: 800, height: 600)
viewer = SCNView(frame: frame)
let menuScene: SCNScene!
menuScene = SCNScene(named: "Scenes.scnassets/Menu.scn")!
viewer.scene = menuScene
override public func keyUp(with event: NSEvent){
viewer.scene = SCNScene(named: "Scenes.scnassets/ScenePR.scn")
}
PlaygroundPage.current.liveView = viewer