SpriteKit side scrolling doesn't update physicsWorld

后端 未结 2 1105
鱼传尺愫
鱼传尺愫 2021-01-27 07:46

Following the example here (except in Objective C) and the standard Apple documentation, I discovered that the physicsWorld doesn\'t update its positions when

2条回答
  •  爱一瞬间的悲伤
    2021-01-27 08:17

    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.

提交回复
热议问题