Child not moving when parent node moves?

前端 未结 1 937
-上瘾入骨i
-上瘾入骨i 2021-01-23 10:12

I have three nodes the world, the player and \"the player vision\". Both the world and the vision SKShapeNodes and my player uses a custom subclass of SKShapeNode. When I move t

相关标签:
1条回答
  • 2021-01-23 10:53

    The problem is that your vision node is affect by the physics engine separately from its parent due to its own physicsBody. The solution is to set the vision node's position property to CGPoint(0, 0) (or whatever you desire it to be in its parent's coordinate system) in the didSimulatePhysics step of the frame. This will have the result of resetting the vision node to "follow" the parent node at all times.

    0 讨论(0)
提交回复
热议问题