【发布时间】:2017-02-28 07:29:47
【问题描述】:
Box2d 中的齿轮接头很棒,但我不知道如何在 Sprite Kit 中实现它。有什么解决方案可以在 Sprite Kit 中实现齿轮接头吗?
谢谢。
【问题讨论】:
标签: ios sprite-kit game-physics
Box2d 中的齿轮接头很棒,但我不知道如何在 Sprite Kit 中实现它。有什么解决方案可以在 Sprite Kit 中实现齿轮接头吗?
谢谢。
【问题讨论】:
标签: ios sprite-kit game-physics
这里是可用的 Sprite-Kit 关节:https://developer.apple.com/reference/spritekit/skphysicsjoint
据我了解,似乎与 Box2D 的齿轮关节没有直接关系,它似乎在另一个身体旋转时使一个身体旋转。
在这种情况下,您可能需要研究覆盖 didSimulatePhysics 或 didFinishUpdate 方法,以根据另一个对象的旋转手动设置一个对象的旋转:
https://developer.apple.com/reference/spritekit/skscene/1519965-didsimulatephysics
https://developer.apple.com/reference/spritekit/skscene/1520269-didfinishupdate
可能很简单:
wheel2.zRotation = wheel1.zRotation
但如果齿轮的齿数不同(因此传动比不同),您就必须进行一些计算。
【讨论】: