使用vertexHelper创建出来的数据
int num = 8;
b2Vec2 verts[8] ;
verts[0].Set(-1.2f / PTM_RATIO, 159.5f / PTM_RATIO);
verts[1].Set(240.7f / PTM_RATIO, -78.4f / PTM_RATIO);
verts[2].Set(56.7f / PTM_RATIO, -108.4f / PTM_RATIO);
verts[3].Set(38.7f / PTM_RATIO, -156.4f / PTM_RATIO);
verts[4].Set(-33.2f / PTM_RATIO, -157.4f / PTM_RATIO);
verts[5].Set(-49.2f / PTM_RATIO, -113.4f / PTM_RATIO);
verts[6].Set(-246.2f / PTM_RATIO, -84.4f / PTM_RATIO);
verts[7].Set(-3.2f / PTM_RATIO, 158.5f / PTM_RATIO);
spriteShape.Set(verts, num);
出现了以下报错:
Assertion failed: (area > 1.19209290e-7F), function ComputeCentroid, file /Users/zeeking/Desktop/游戏设计大赛/flyflykite/flyflykite/libs/Box2D/Collision/Shapes/b2PolygonShape.cpp, line 115.
问题原因:
vertexHelper使用不当,应该按 逆时针 而非 顺时针
解决方法:
重新定义即可