且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

SpriteKit 侧滚动不更新physicsWorld

更新时间:2023-11-17 16:44:22

我不知道过去 2 年发生了什么变化,但这里的另一个答案不再起作用.相反,现在我将绳段位置与其父级(完整的绳索)结合起来.所以我只是这样做

I don't know what's changed in the last 2 years, but the other answer here didn't work anymore. Instead, now I combine the rope segments position with its parent's (the full rope). So I just do

CGPoint convertedRopePosition = CGPointMake(ropePhysicsBody.node.parent.position.x + ropePhysicsBody.node.position.x, ropePhysicsBody.node.parent.position.y + ropePhysicsBody.node.position.y);
SKPhysicsJointPin *jointPin = [SKPhysicsJointPin jointWithBodyA:monkeyPhysicsBody bodyB:ropePhysicsBody anchor:convertedRopePosition];

这是必需的,因为绳子段放置在绳子的全长之下,所以它的位置是相对于整个绳子而不是场景.

This is needed because the rope segment is placed under the full length of the rope, so it's position is relative to the full rope rather than the scene.