当动态体坍塌时,其`_ball.position.y`值不会改变

时间:2015-02-02 19:27:07

标签: scenekit

我有一个非常简单的问题 -

func setupScene() {
        let sceneView = view as SCNView
        sceneView.backgroundColor = SKColor.blackColor()
        _scene = SCNScene()
        sceneView.scene = _scene

        sceneView.showsStatistics = true
//        Scene gravity
        sceneView.scene?.physicsWorld.gravity = SCNVector3Make(0, -70, 0)
        sceneView.scene?.physicsWorld.speed = 2.0
        sceneView.delegate = self
}

在某些时候有spawnBall方法:

 func spawnBall() {
        _ball = SCNNode(geometry: SCNSphere(radius: 15))
        _ball.geometry?.firstMaterial?.diffuse.contents = UIImage(named: "ball")
        _ball.geometry?.firstMaterial?.emission.contents = UIImage(named: "ball")
        _ball.geometry?.firstMaterial?.emission.intensity = 0
        _ball.physicsBody = SCNPhysicsBody(type: SCNPhysicsBodyType.Dynamic, shape: nil)
        _ball.physicsBody?.restitution = 0.1
        _ball.physicsBody?.angularVelocity = SCNVector4(x: 1, y: 1, z: 1, w: 1)

        let position = SCNVector3Make(0, 15*10, -200)
        _ball.position = position
        _scene.rootNode.addChildNode(_ball)

    }

问题是 - 为什么当动态体坍塌时,它的_ball.position.y值不会改变?

当你移动UIKit时,我曾经UIView - 它的原点发生了变化(我假设看到类似的东西,因为我设置了_ball.position.y = 150它应该会失效) 以及如何观察它的运动?

1 个答案:

答案 0 :(得分:0)

position的{​​{1}}会发生变化。物理引擎保持模型值不受影响。