1. If you want to set an object with a polygonal body, so that more accurate collision detection, you can use the following methods
Auto hero = Planehero::create ();
AddChild (Hero, 0, Hero_tag);
Hero->setposition (VEC2 (WINSIZE.WIDTH/2, Hero->getcontentsize (). HEIGHT/2 + 10));
Auto Herobody = Physicsbody::createbox (Hero->getcontentsize ()); This setting is not very precise.
Auto Herobody = Physicsbody::create ();
VEC2 verts[] = {VEC2 (0), VEC2 ( -30), VEC2 (-50,-30)}; A polygon is formed from a point so that the physicsbody set is a triangle
Herobody->addshape (Physicsshapeedgepolygon::create (Verts, 3));
Herobody->setcollisionbitmask (0x0); No collision simulation
Herobody->setcontacttestbitmask (Hero_contactmaskbit);
Hero->setphysicsbody (Herobody);
2. About the Physicsshapeedgepolygon function
Static physicsshapeedgepolygon* Create (const VEC2 * points, int count, const physicsmaterial & material = Physicss Hape_material_default, float border = 1)
An array of points polygon vertices.
Count Polygon Vertex count.
MATERIAL physical Material Physicsmaterial object, default value is Physicsshape_material_default.
Border This is the border width of the polygon.
Example
VEC2 verts[] = {VEC2 (0), VEC2 ( -30), VEC2 (-50,-30)}; Make a polygon based on points
Herobody->addshape (Physicsshapeedgepolygon::create (Verts, 3));
On the setting of the physical rigid body of polygons in cocos2d-x