Does anyone know what is the best method to create a st开发者_如何转开发atic ground body with many (~10000) vertices in Box2D (the version that comes with Cocos2D).
This is what I do now for cubic beziers, it looks fine but runs a bit slow.
for (int i = 0; i<segments; i++) {
CGPoint p2 = vertices[i+1];
CGPoint p1 = vertices[i];
b2PolygonShape poly;
poly.SetAsEdge(b2Vec2(p1.x,p1.y), b2Vec2(p2.x, p2.y));
groundBody->CreateFixture(&poly,0);
}
People talk about b2LoopShape but it doesn't seem like it's included in the Box2d version shipped with Cocos?
Any ideas?
For b2LoopShape, you need to replace external/Box2d with Box2D trunk.
- checkout Box2D trunk from box2d.
- replace cocos2d/external/Box2d with trunk/Box2D/Box2D.
- modify Xcode project for added Box2D files.
- modify some codes for renamed classes such as s/b2DebugDraw/b2Draw/.
精彩评论