How to make a b2EdgeShape? Making a simple b2EdgeShape. Simple boilerplate b2EdgeShape to build on top of.
My code:
var bodyDef = new Box2D.Dynamics.b2BodyDef;
bodyDef.type = Box2D.Dynamics.b2Body.b2_staticBody;
bodyDef.position.SetV(new Box2D.Common.Math.b2Vec2(250/30, 250/30));
var fixtureDef = new Box2D.Dynamics.b2FixtureDef;
fixtureDef.shape = new Box2D.Collision.Shapes.b2EdgeShape(
new Box2D.Common.Math.b2Vec2(2.5,0),
new Box2D.Common.Math.b2Vec2(2.5,2.5));
fixtureDef.density = 0;
fixtureDef.restitution = 0.0;
fixtureDef.friction = 0.0;
var body = world.CreateBody(bodyDef);
var fixture = body.CreateFixture(fixtureDef);
There is no way to use b2EdgeShape yet. It is not fully implemented in box2dweb.
Instead of b2EdgeShape you can use b2PolygonShape as follows:
fixDef.shape = new b2PolygonShape()
fixDef.shape.SetAsEdge(new b2Vec2(x1, y1), new b2Vec2(x2, y2))