我想在运行时创建行box2d(触摸事件)
我创造了以上内容。但我有问题。问题是未检测到线形(b2EdgeShape)或地箱中的碰撞,这也是b2EdgeShape。
以下是编码:
初始化功能:
b2EdgeShape groundBox;
// bottom
groundBox.Set(b2Vec2(0,0), b2Vec2((s.width)/PTM_RATIO,0));
groundBody->CreateFixture(&groundBox,0);
CCTouch活动:
b2EdgeShape shape1;
b2FixtureDef fdf;
fdf.density = 1.0;
fdf.friction = 0.3;
fdf.restitution = 0.2;
fdf.shape=&shape1;
shape1.Set(b2Vec2(s.x, s.y), b2Vec2(e.x, e.y));
body->CreateFixture(&shape1,0.0f);
有任何错误或逻辑问题吗?
答案 0 :(得分:4)
Two edge shapes cannot collide with each other.
根据Box2d手册.......
A major limitation of edge shapes is that they can collide with circles and polygons but
not with themselves. The collision algorithms used by Box2D require that at least one of two colliding
shapes have volume. Edge shapes have no volume, so edge-edge collision is not possible.