com.badlogic.gdx.physics.box2d.Body.isActive()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(4.7k)|赞(0)|评价(0)|浏览(119)

本文整理了Java中com.badlogic.gdx.physics.box2d.Body.isActive()方法的一些代码示例,展示了Body.isActive()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Body.isActive()方法的具体详情如下:
包路径:com.badlogic.gdx.physics.box2d.Body
类名称:Body
方法名:isActive

Body.isActive介绍

[英]Get the active state of the body.
[中]获取身体的活动状态。

代码示例

代码示例来源:origin: libgdx/libgdx

private Color getColorByBody (Body body) {
  if (body.isActive() == false)
    return SHAPE_NOT_ACTIVE;
  else if (body.getType() == BodyType.StaticBody)
    return SHAPE_STATIC;
  else if (body.getType() == BodyType.KinematicBody)
    return SHAPE_KINEMATIC;
  else if (body.isAwake() == false)
    return SHAPE_NOT_AWAKE;
  else
    return SHAPE_AWAKE;
}

代码示例来源:origin: libgdx/libgdx

private void renderBodies (World world) {
  renderer.begin(ShapeType.Line);
  if (drawBodies || drawAABBs) {
    world.getBodies(bodies);
    for (Iterator<Body> iter = bodies.iterator(); iter.hasNext();) {
      Body body = iter.next();
      if (body.isActive() || drawInactiveBodies) renderBody(body);
    }
  }
  if (drawJoints) {
    world.getJoints(joints);
    for (Iterator<Joint> iter = joints.iterator(); iter.hasNext();) {
      Joint joint = iter.next();
      drawJoint(joint);
    }
  }
  renderer.end();
  if (drawContacts) {
    renderer.begin(ShapeType.Point);
    for (Contact contact : world.getContactList())
      drawContact(contact);
    renderer.end();
  }
}

代码示例来源:origin: libgdx/libgdx

private void renderBodies (World world) {
  renderer.begin(ShapeType.Line);
  if (drawBodies || drawAABBs) {
    world.getBodies(bodies);
    for (Iterator<Body> iter = bodies.iterator(); iter.hasNext();) {
      Body body = iter.next();
      if (body.isActive() || drawInactiveBodies) renderBody(body);
    }
  }
  if (drawJoints) {
    world.getJoints(joints);
    for (Iterator<Joint> iter = joints.iterator(); iter.hasNext();) {
      Joint joint = iter.next();
      drawJoint(joint);
    }
  }
  renderer.end();
  if (drawContacts) {
    renderer.begin(ShapeType.Point);
    for (Contact contact : world.getContactList())
      drawContact(contact);
    renderer.end();
  }
}

代码示例来源:origin: libgdx/libgdx

protected void renderBody (Body body) {
  Transform transform = body.getTransform();
  int len = body.getFixtureList().size;
  Array<Fixture> fixtures = body.getFixtureList();
  for (int i = 0; i < len; i++) {
    Fixture fixture = fixtures.get(i);
    if (drawBodies) {
      if (body.isActive() == false && drawInactiveBodies)
        drawShape(fixture, transform, SHAPE_NOT_ACTIVE);
      else if (body.getType() == BodyType.StaticBody)
        drawShape(fixture, transform, SHAPE_STATIC);
      else if (body.getType() == BodyType.KinematicBody)
        drawShape(fixture, transform, SHAPE_KINEMATIC);
      else if (body.isAwake() == false)
        drawShape(fixture, transform, SHAPE_NOT_AWAKE);
      else
        drawShape(fixture, transform, SHAPE_AWAKE);
    }
    if (drawAABBs) {
      drawAABB(fixture, transform);
    }
  }
}

代码示例来源:origin: dozingcat/Vector-Pinball

public boolean isRetracted() {
  return wallBody!=null && !wallBody.isActive();
}

代码示例来源:origin: manuelbua/uracer-kotd

public boolean isActive () {
  return body.isActive();
}

代码示例来源:origin: dozingcat/Vector-Pinball

/** Returns true if all targets have been hit (and their corresponding bodies made inactive) */
public boolean allTargetsHit() {
  int bsize = allBodies.size();
  for (int i=0; i<bsize; i++) {
    if (allBodies.get(i).isActive()) return false;
  }
  return true;
}

代码示例来源:origin: manuelbua/uracer-kotd

public void setActive (boolean active) {
  if (active != body.isActive()) {
    body.setActive(active);
  }
}

代码示例来源:origin: dozingcat/Vector-Pinball

@Override public void draw(IFieldRenderer renderer) {
    // draw line for each target
    Color color = currentColor(DEFAULT_COLOR);
    int bsize = allBodies.size();
    for(int i=0; i<bsize; i++) {
      Body body = allBodies.get(i);
      if (body.isActive()) {
        float[] parray = positions[i];
        renderer.drawLine(parray[0], parray[1], parray[2], parray[3], color);
      }
    }
  }
}

代码示例来源:origin: com.badlogicgames.gdx/gdx-box2d

private Color getColorByBody (Body body) {
  if (body.isActive() == false)
    return SHAPE_NOT_ACTIVE;
  else if (body.getType() == BodyType.StaticBody)
    return SHAPE_STATIC;
  else if (body.getType() == BodyType.KinematicBody)
    return SHAPE_KINEMATIC;
  else if (body.isAwake() == false)
    return SHAPE_NOT_AWAKE;
  else
    return SHAPE_AWAKE;
}

代码示例来源:origin: dsaltares/libgdx-cookbook

public void interpolate(float alpha) {
  for (Box box : activeBoxes) {
    Body body = box.getBody();
    if(body.isActive()) {
      Transform transform = body.getTransform();
      Vector2 bodyPosition = transform.getPosition();
      float bodyAngle = transform.getRotation();

      box.x = bodyPosition.x * alpha + box.x * (1.0f - alpha);
      box.y = bodyPosition.y * alpha + box.y * (1.0f - alpha);
      box.angle = bodyAngle * alpha + box.angle * (1.0f - alpha);
    }
  }
}

代码示例来源:origin: com.badlogicgames.gdx/gdx-box2d

private void renderBodies (World world) {
  renderer.begin(ShapeType.Line);
  if (drawBodies || drawAABBs) {
    world.getBodies(bodies);
    for (Iterator<Body> iter = bodies.iterator(); iter.hasNext();) {
      Body body = iter.next();
      if (body.isActive() || drawInactiveBodies) renderBody(body);
    }
  }
  if (drawJoints) {
    world.getJoints(joints);
    for (Iterator<Joint> iter = joints.iterator(); iter.hasNext();) {
      Joint joint = iter.next();
      drawJoint(joint);
    }
  }
  renderer.end();
  if (drawContacts) {
    renderer.begin(ShapeType.Point);
    for (Contact contact : world.getContactList())
      drawContact(contact);
    renderer.end();
  }
}

相关文章