【问题标题】:I joined multiple images into a rope. How can I decrease the rope stretchiness?我将多个图像连接成一根绳子。我怎样才能减少绳索的弹性?
【发布时间】:2015-12-27 18:13:54
【问题描述】:

我根据this 教程创建了一根绳子,但我的绳子在绳子的每一端都有一个球。

高级:这就是他们制作绳索的方式。

  1. 创建SKNodes 的数组
  2. 将每个绳索段(节点)附加到数组中
  3. 将每个节点添加到屏幕
  4. 将每个节点连接在一起形成一根绳子
  5. (然后我在绳子的每一端添加一个球)

在我的程序中,我移动球并基本上像一个有弹性的钟摆一样摆动绳索。

这是我的问题:如果我用力摆动绳子,绳子就会拉得太长!如何减少绳索的拉伸量?我没有看到降低身体弹性的方法。

如果有任何其他有用的信息,请告诉我!提前致谢

【问题讨论】:

    标签: ios swift sprite-kit verlet-integration elasticity


    【解决方案1】:

    你可以试试这两种方法。第一种方法是增加SKPhysicsJointPin类的属性frictionTorque

    值的范围是从 0.0 到 1.0。默认值为 0.0。如果一个 指定大于默认值的值,摩擦应用于 减小物体绕销的角速度。

    您遵循的教程的示例,在将joint 添加到场景之前,修改frictionTorque

    for i in 1...length {
        let nodeA = ropeSegments[i - 1]
        let nodeB = ropeSegments[i]
        let joint = SKPhysicsJointPin.jointWithBodyA(nodeA.physicsBody!, bodyB: nodeB.physicsBody!,
            anchor: CGPointMake(CGRectGetMidX(nodeA.frame), CGRectGetMinY(nodeA.frame)))
        joint.frictionTorque = 0.5    // Add this line
    
        scene.physicsWorld.addJoint(joint)
    }
    

    第二种方法是限制销接头的摆动角度。启用shouldEnableLimits后,调整lowerAngleLimitupperAngleLimit的弧度。

    详细了解Determining the Characteristics of the Pin Joint 的 SKPhysicsJointPin 类参考。

    【讨论】:

    • 感谢您的回复。我只是尝试更改frictionTorque,打开shouldEnableLimits 并调整上限/下限。什么都没有改变,还有其他想法吗?
    • 我想通了!改变绳子的密度可以解决拉伸问题
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多