private Body createEdge (BodyType type, float x1, float y1, float x2, float y2, float density) { BodyDef def = new BodyDef(); def.type = type; Body box = world.createBody(def); EdgeShape poly = new EdgeShape(); poly.set(new Vector2(0, 0), new Vector2(x2 - x1, y2 - y1)); box.createFixture(poly, density); box.setTransform(x1, y1, 0); poly.dispose(); return box; }
Body ground = world.createBody(bd); ground.createFixture(fd); shape.dispose();
@Override protected void createWorld (World world) { { BodyDef bd = new BodyDef(); Body ground = world.createBody(bd); EdgeShape shape = new EdgeShape(); shape.set(new Vector2(-40, 0), new Vector2(40, 0)); ground.createFixture(shape, 0); shape.dispose(); } { CircleShape shape = new CircleShape(); shape.setRadius(1.0f); for (int i = 0; i < e_count; i++) { BodyDef bd = new BodyDef(); bd.type = BodyType.DynamicBody; bd.position.set(0, 4.0f + 3.0f * i); Body body = world.createBody(bd); body.createFixture(shape, 1.0f); } shape.dispose(); } }
shape.set(new Vector2(-40, 0), new Vector2(40, 0)); ground.createFixture(shape, 0.0f); shape.dispose();
shape.set(new Vector2(-40, 0), new Vector2(40, 0)); ground.createFixture(shape, 0); shape.dispose();
shape.dispose();
shape.set(new Vector2(-40, 0), new Vector2(40, 0)); ground.createFixture(shape, 0.0f); shape.dispose();
shape.dispose();
@Override protected void createWorld (World world) { { BodyDef bd = new BodyDef(); bd.position.set(0, 0); Body body = world.createBody(bd); EdgeShape shape = new EdgeShape(); shape.set(new Vector2(-10, 0), new Vector2(10, 0)); body.createFixture(shape, 0); shape.dispose(); PolygonShape poly = new PolygonShape(); poly.setAsBox(0.2f, 1.0f, new Vector2(0.5f, 1.0f), 0); body.createFixture(poly, 0); poly.dispose(); } { BodyDef bd = new BodyDef(); bd.type = BodyType.DynamicBody; bd.position.set(0, 20); PolygonShape shape = new PolygonShape(); shape.setAsBox(2, 0.1f); m_body = world.createBody(bd); m_body.createFixture(shape, 1); m_angularVelocity = 33.468121f; m_body.setLinearVelocity(new Vector2(0, -100)); m_body.setAngularVelocity(m_angularVelocity); shape.dispose(); } }
shape.set(new Vector2(-20.0f, 0), new Vector2(20.0f, 0f)); ground.createFixture(shape, 0); shape.dispose();
shape.set(new Vector2(-20, 0), new Vector2(20, 0)); ground.createFixture(shape, 0); shape.dispose(); shape.set(new Vector2(-4, 1), new Vector2(-2, 1)); ground.createFixture(shape, 0); shape.dispose(); shape.set(new Vector2(-1, 5 - d), new Vector2(-1, 3 + d)); ground.createFixture(shape, 0); shape.dispose();
shape.set(new Vector2(-20, 0), new Vector2(20, 0)); ground.createFixture(shape, 0); shape.dispose(); shape.set(new Vector2(-4, 1), new Vector2(-2, 1)); ground.createFixture(shape, 0); shape.dispose(); shape.set(new Vector2(-1, 5 - d), new Vector2(-1, 3 + d)); ground.createFixture(shape, 0); shape.dispose();
fd.shape = shape; ground.createFixture(fd); shape.dispose();
shape.dispose();
ground.createFixture(sd); shape.dispose();
Body ground = world.createBody(bd); ground.createFixture(fd); shape.dispose();
shape.set(new Vector2(-40, 0), new Vector2(40, 0)); ground.createFixture(shape, 0); shape.dispose();
public static Body createEdge(World world, BodyType type, float x1, float y1, float x2, float y2, float density) { synchronized(world){ BodyDef def = new BodyDef(); def.type = type; Body box = world.createBody(def); EdgeShape boxShape = new EdgeShape(); boxShape.set(new Vector2(0, 0), new Vector2(x2 - x1, y2 - y1)); /*Fixture fixture = */box.createFixture(boxShape, density); box.setTransform(x1, y1, 0); boxShape.dispose(); return box; } }