我正在完全遵循教程,当教程说运行程序时我得到一个错误,“类gameviewcontroller没有initalizers”
我完全复制了它,所以我不知道出了什么问题,但我认为可能是在我重新检索节点时。
var cameraNode: SCNNode
var shelfNode: SCNNode
var baseCanNode: SCNNode
func createScene(){
cameraNode = levelScene.rootNode.childNode(withName: "camera", recursively: true)!
shelfNode = levelScene.rootNode.childNode(withName: "shelf", recursively: true)!
guard let canScene = SCNScene(named: "resources.scnassets/Can.scn") else { return }
baseCanNode = canScene.rootNode.childNode(withName: "can", recursively: true)!
}
请告诉我我做错了什么。
谢谢。
答案 0 :(得分:1)
只需在末尾添加惊叹号
var cameraNode: SCNNode!
var shelfNode: SCNNode!
var baseCanNode: SCNNode!
而不是
var cameraNode: SCNNode
var shelfNode: SCNNode
var baseCanNode: SCNNode