1

我最近更新到最新的 Xcode 8 beta 6。我之前是 beta 4(我想)。我试图编译我的代码并得到这个错误:

在此处输入图像描述

这是片段:

private func setupPlane() {

    // create plane geometry with size and material properties
    let myPlane = SCNPlane(width: 10000.0, height: 10000.0)
    myPlane.firstMaterial!.diffuse.contents = NSColor.orange.cgColor
    myPlane.firstMaterial!.specular.contents = NSColor.white.cgColor

    // intialize noe
    let planeNode = SCNNode()
    // assign plane geometry to the node
    planeNode.geometry = myPlane

    // rotate -90.0 about the x-axis
    let rotMat = SCNMatrix4MakeRotation(-CGFloat(M_PI/3.0), 1.0, 0.0, 0.0)
    planeNode.transform = rotMat
    planeNode.position = SCNVector3Make(0.0, 0.0, 0.0)

    // setup the node's physics body property
    planeNode.physicsBody = SCNPhysicsBody(type: .static, shape: SCNPhysicsShape(geometry: myPlane, options: nil))
    planeNode.physicsBody!.categoryBitMask = PhysicsMask3DOF.plane.rawValue

    // add to scene
    sceneView.scene!.rootNode.addChildNode(planeNode)
}

如果我注释掉分配物理体的两行,然后设置其类别,则代码编译时错误为零。我不太清楚错误试图暗示什么。任何建议都非常感谢。

4

1 回答 1

2

这是编译器中的一个已知问题。作为一种解决方法,您可以使用[:]而不是nil

SCNPhysicsShape(geometry: myPlane, options: [:])
于 2016-08-26T09:02:35.403 回答