Package org.jbox2d.dynamics

Examples of org.jbox2d.dynamics.Body.createFixture()


      BodyDef bd = new BodyDef();
      Body ground = getWorld().createBody(bd);

      EdgeShape shape = new EdgeShape();
      shape.set(new Vec2(-40.0f, 0.0f), new Vec2(40.0f, 0.0f));
      ground.createFixture(shape, 0.0f);
    }

    // Breakable dynamic body
    {
      BodyDef bd = new BodyDef();
View Full Code Here


    bd.type = BodyType.DYNAMIC;
    bd.position = body1.getPosition();
    bd.angle = body1.getAngle();

    Body body2 = getWorld().createBody(bd);
    m_piece2 = body2.createFixture(m_shape2, 1.0f);

    // Compute consistent velocities for new bodies based on
    // cached velocity.
    Vec2 center1 = body1.getWorldCenter();
    Vec2 center2 = body2.getWorldCenter();
View Full Code Here

      BodyDef bd = new BodyDef();
      ground = getWorld().createBody(bd);

      EdgeShape shape = new EdgeShape();
      shape.set(new Vec2(-40.0f, 0.0f), new Vec2(40.0f, 0.0f));
      ground.createFixture(shape, 0.0f);
    }

    {
      PolygonShape shape = new PolygonShape();
      shape.setAsBox(0.6f, 0.125f);
View Full Code Here

      for (int i = 0; i < 30; ++i) {
        BodyDef bd = new BodyDef();
        bd.type = BodyType.DYNAMIC;
        bd.position.set(0.5f + i, y);
        Body body = getWorld().createBody(bd);
        body.createFixture(fd);

        Vec2 anchor = new Vec2(i, y);
        jd.initialize(prevBody, body, anchor);
        getWorld().createJoint(jd);
View Full Code Here

      shape.setAsBox(10.0f, 0.5f);

      FixtureDef fd = new FixtureDef();
      fd.shape = shape;
      fd.friction = 0.8f;
      m_platform = body.createFixture(fd);
    }

    // Boxes
    for (int i = 0; i < 5; ++i) {
      BodyDef bd = new BodyDef();
View Full Code Here

      bd.position.set(-10.0f + 2.0f * i, 7.0f);
      Body body = m_world.createBody(bd);

      PolygonShape shape = new PolygonShape();
      shape.setAsBox(0.5f, 0.5f);
      body.createFixture(shape, 20.0f);
    }
  }

  @Override
  public void preSolve(Contact contact, Manifold oldManifold) {
View Full Code Here

      bd.type = BodyType.DYNAMIC;
      Body body = m_world.createBody(bd);
      CircleShape shape = new CircleShape();
      shape.m_p.set(0, 80);
      shape.m_radius = 5;
      body.createFixture(shape, 0.5f);
    }

  }
}
View Full Code Here

        float x2 = x1 + 0.5f;
        float y2 = 2.0f * MathUtils.cos(x2 / 10.0f * MathUtils.PI);

        EdgeShape shape = new EdgeShape();
        shape.set(new Vec2(x1, y1), new Vec2(x2, y2));
        ground.createFixture(shape, 0.0f);

        x1 = x2;
        y1 = y2;
      }
    }
View Full Code Here

      BodyDef bd = new BodyDef();
      ground = getWorld().createBody(bd);

      EdgeShape shape = new EdgeShape();
      shape.set(new Vec2(-40.0f, 0.0f), new Vec2(40.0f, 0.0f));
      ground.createFixture(shape, 0.0f);
    }

    {
      PolygonShape shape = new PolygonShape();
      shape.setAsBox(2.0f, 0.5f);
View Full Code Here

      bd.type = BodyType.DYNAMIC;
      bd.position.set(-10.0f, 10.0f);
      bd.angle = 0.5f * MathUtils.PI;
      bd.allowSleep = false;
      Body body = getWorld().createBody(bd);
      body.createFixture(shape, 5.0f);

      PrismaticJointDef pjd = new PrismaticJointDef();

      // Bouncy limit
      Vec2 axis = new Vec2(2.0f, 1.0f);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.