Today, let's take a look at how to create an irregular shape.
In box2d, you can set multiple vertex for a shape, so that you may generate a custom shape, such
In this way, a custom shape is created. Note the following when creating a custom shape:
1. the vertex position is relative to the center of the body
2. the vertex needs to be defined clockwise.
3. the maximum number of vertices cannot exceed 8. The larger the number, the more expensive the memory, the worse the performance.
4. A concave cannot be defined for a vertex)
What is concave and convex?
There is a small tool used to get the vertex value, called vertex helper ,:Https://github.com/jfahrenkrug/VertexHelper
You need to use xcode to open the file. After opening the file, drag your image to vertex helper, click Edit mode, select box2d for type, select initialization for style, and click on the image with the mouse.