SKPhysicsJointPin pin position

拥有回忆 提交于 2019-12-12 01:56:26

问题


I'm trying to understand SKPhysicsJointPin a bit better, specifically the anchor point parameter.

I understand that the anchor point is the position in the parent node of the two physics bodies concerned. What I don't understand at which point in the participating bodies does the pin go through and if there is a way to control that.

To make myself clear, say I'm making a clock with hands so the pin should go in the middle of the circle but for the hands is should go through the edge. So how can you control that.

Thanks a bunch.


回答1:


Documentation is pretty lacking for these. To use the clock reference, and since you obviously know the code, I'll give you the English breakdown:

  1. add 2 clock hand sprites to the scene
  2. set both anchor points on the clock hand sprites to (.5,0)
  3. position both sprites at (100,100)
  4. create 2 physics bodies, add them to each clock hand
  5. create the SKPhysicsJointPin, use anchor point (100,100)
  6. add the joint to the scene

You should in theory, now have 2 clock hands, able to spin via their own anchor points around the point in the scene at (100,100).



来源:https://stackoverflow.com/questions/24540962/skphysicsjointpin-pin-position

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!