我正在尝试使用 SceneKit 为 WWDC 学生挑战赛做一些事情,这要求我的项目在 Swift 游乐场中。我不断收到“运行此页面时出现问题”的消息。它不提供错误消息。它只是建议检查我的代码或重新开始。我曾尝试单独删除代码段,但找不到此问题的根源。我还尝试在 man Xcode playground 中运行它,它提供了警告,我引用“操场无法继续运行,因为操场源代码做到了”。我被困住了。我的代码有什么问题。
import UIKit
import SceneKit
import QuartzCore
import PlaygroundSupport
class GameScene: UIViewController, SCNSceneRendererDelegate {
var primaryView: SCNView!
var primaryScene: SCNScene!
var cameraNode: SCNNode!
override func viewDidLoad() {
sceneAndViewInit()
cameraInit()
createGround()
moonInit()
}
func createGround() {
var ground = SCNBox(width: 200, height: 1, length: 200, chamferRadius: 0)
var groundPhysicsShape = SCNPhysicsShape(geometry: ground, options: nil)
var groundNode = SCNNode(geometry: ground)
ground.firstMaterial?.diffuse.contents = UIColor.orange
ground.firstMaterial?.specular.contents = UIColor.white
groundNode.position = SCNVector3(0, -6, 0)
groundNode.physicsBody …Run Code Online (Sandbox Code Playgroud)