I want to create a static body with two rectangles in processing, and i want them to be like an “L”, but now the two rectangles are placed in the middle, and I don’t know how to fix that. Any suggestion will be appreciated!
Here is a screenshot:
void makeBody(Vec2 center) {
BodyDef bd = new BodyDef();
bd.type = BodyType.STATIC;
bd.position.set(box2d.coordPixelsToWorld(center));
body = box2d.createBody(bd);
PolygonShape sd = new PolygonShape();
float box2dW = box2d.scalarPixelsToWorld(w/2);
float box2dH = box2d.scalarPixelsToWorld(h/2);
sd.setAsBox(box2dW/2, box2dH);
body.createFixture(sd, 1.0);
PolygonShape sd2 = new PolygonShape();
float box2dW2 = box2d.scalarPixelsToWorld(w/2);
float box2dH2 = box2d.scalarPixelsToWorld(h/2);
sd2.setAsBox(box2dW2, box2dH2/2);
body.createFixture(sd2, 1.0);
}
}