iOS - bodyWithPolygonFromPath : Body is the same as the path but collisions are not working properly

我的未来我决定 提交于 2019-12-03 16:36:14

The shape in the first screenshot is convex but the shape in the second screenshot is concave.

The physics polygon shapes need to be convex for them to work correctly. You can do one of two things:

  • Create two nodes and two bodies whose individual shapes are convex but together they form the concave shape. These bodies can be dynamic. You may want to set them to static or connect them together with a rigid distance joint, or otherwise ensure they are not going to move apart.
  • Use bodyWithEdgeLoopFromPath: or bodyWithEdgeChainFromPath: to be able to create concave collision shapes. These bodies will not be dynamic and won't be able to move by themselves but they are the perfect solution for arbitrary collision shapes with a static playfield.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!