且构网

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

SpriteKit侧滚动不会更新physicsWorld

更新时间:2023-11-17 16:35:52

我不知道过去两年有什么变化,但这里的另一个答案已不再适用了。相反,现在我将绳段位置与其父级(完整绳索)组合在一起。所以我只做

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.