Example #1
0
    @Override
    protected void bodyDefB4CreationCallback(BodyDef def) {
      super.bodyDefB4CreationCallback(def);
      //			def.linearDamping = 0.15f;
      def.linearDamping = 0.25f;
      def.isBullet = true;
      def.angularDamping = 0.9f;

      //			def.fixedRotation = true;
    }
Example #2
0
  /**
   * Create a new paddle.
   *
   * @param world The world the paddle will be added to.
   * @param y The height of the paddle (starts centered on the x)
   * @param mode The keys that will move this paddle
   */
  public Paddle(World world, int y, MovementMode mode) {
    Mode = mode;

    // Respond to the keyboard
    KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
    manager.addKeyEventDispatcher(this);

    // Add the physics body
    BodyDef bd = new BodyDef();
    bd.type = BodyType.DYNAMIC;
    bd.position.set(world.Bounds.width / 2, y);
    bd.linearDamping = 0.0f;
    bd.angularDamping = 0.01f;

    FixtureDef fd = new FixtureDef();
    fd.shape = new PolygonShape();
    ((PolygonShape) fd.shape).setAsBox(SIZE.width / 2, SIZE.height / 2);
    fd.density = 0.1f;
    fd.friction = 0.0f;
    fd.restitution = 1.0f;

    j2dBody = world.j2dWorld.createBody(bd);
    j2dBody.createFixture(fd);
    j2dBody.setUserData(this);

    // Limit it to only x movement
    BodyDef gbd = new BodyDef();
    gbd.type = BodyType.STATIC;
    bd.position.set(world.Bounds.width / 2, y);

    PrismaticJointDef pjd = new PrismaticJointDef();
    pjd.collideConnected = true;
    pjd.initialize(
        j2dBody, world.j2dWorld.createBody(gbd), j2dBody.getWorldCenter(), new Vec2(1.0f, 0.0f));
    world.j2dWorld.createJoint(pjd);
  }
Example #3
0
File: Body.java Project: rdo/speleo
 /**
  * Set the linear damping to apply to this body. Higher value slows the body acceleration. Maximum
  * is 1.0
  *
  * @param damping The amount to dampen the movement by
  */
 public void setDamping(float damping) {
   if (jboxBody == null) {
     jboxBodyDef.linearDamping = damping;
   }
 }
Example #4
0
 @Override
 protected void bodyDefB4CreationCallback(BodyDef def) {
   super.bodyDefB4CreationCallback(def);
   def.fixedRotation = true;
   def.linearDamping = 0.5f;
 }