Box2d Loop Shape / 在 Cocos2D 中创建静态地面形状
有谁知道在 Box2D(Cocos2D 附带的版本)中创建具有许多(~10000)个顶点的静态地面体的最佳方法是什么。
这就是我现在对三次贝塞尔曲线所做的,它看起来不错,但运行有点慢。
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);
}
人们谈论 b2LoopShape 但它似乎没有包含在 Cocos 附带的 Box2d 版本中?
有什么想法吗?
Does anyone know what is the best method to create a static 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于b2LoopShape,您需要将external/Box2d替换为Box2D trunk。
For b2LoopShape, you need to replace external/Box2d with Box2D trunk.