org.jbox2d.dynamics.Body.destroyFixture()方法的使用及代码示例

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

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

Body.destroyFixture介绍

[英]Destroy a fixture. This removes the fixture from the broad-phase and destroys all contacts associated with this fixture. This will automatically adjust the mass of the body if the body is dynamic and the fixture has positive density. All fixtures attached to a body are implicitly destroyed when the body is destroyed.
[中]

代码示例

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

/** Destroy a fixture. This removes the fixture from the broad-phase and destroys all contacts associated with this fixture.
 * This will automatically adjust the mass of the body if the body is dynamic and the fixture has positive density. All
 * fixtures attached to a body are implicitly destroyed when the body is destroyed.
 * @param fixture the fixture to be removed.
 * @warning This function is locked during callbacks. */
public void destroyFixture (Fixture fixture) {
  body.destroyFixture(fixture.fixture);
  fixtures.removeValue(fixture, true);
  world.fixtures.remove(fixture.fixture);
}

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

@Override
public void step(TestbedSettings settings) {
 if (nextShape != null) {
  m_body.destroyFixture(currFixture);
  currFixture = m_body.createFixture(nextShape, 1f);
  nextShape = null;

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

@Override
public void keyPressed(char key, int argKeyCode) {
 switch (key) {
  case 'c':
   if (m_fixture2 == null) {
    CircleShape shape = new CircleShape();
    shape.m_radius = 3.0f;
    shape.m_p.set(0.5f, -4.0f);
    m_fixture2 = m_body.createFixture(shape, 10.0f);
    m_body.setAwake(true);
   }
   break;
  case 'd':
   if (m_fixture2 != null) {
    m_body.destroyFixture(m_fixture2);
    m_fixture2 = null;
    m_body.setAwake(true);
   }
   break;
 }
}

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

void Break() {
 // Create two bodies from one.
 Body body1 = m_piece1.getBody();
 Vec2 center = body1.getWorldCenter();
 body1.destroyFixture(m_piece2);
 m_piece2 = null;
 BodyDef bd = new BodyDef();
 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();
 Vec2 velocity1 = m_velocity.add(Vec2.cross(m_angularVelocity, center1.sub(center)));
 Vec2 velocity2 = m_velocity.add(Vec2.cross(m_angularVelocity, center2.sub(center)));
 body1.setAngularVelocity(m_angularVelocity);
 body1.setLinearVelocity(velocity1);
 body2.setAngularVelocity(m_angularVelocity);
 body2.setLinearVelocity(velocity2);
}

代码示例来源:origin: org.jbox2d/jbox2d-testbed

@Override
public void step(TestbedSettings settings) {
 if (nextShape != null) {
  m_body.destroyFixture(currFixture);
  currFixture = m_body.createFixture(nextShape, 1f);
  nextShape = null;

代码示例来源:origin: org.jbox2d/jbox2d-testbed

@Override
public void keyPressed(char key, int argKeyCode) {
 switch (key) {
  case 'c':
   if (m_fixture2 == null) {
    CircleShape shape = new CircleShape();
    shape.m_radius = 3.0f;
    shape.m_p.set(0.5f, -4.0f);
    m_fixture2 = m_body.createFixture(shape, 10.0f);
    m_body.setAwake(true);
   }
   break;
  case 'd':
   if (m_fixture2 != null) {
    m_body.destroyFixture(m_fixture2);
    m_fixture2 = null;
    m_body.setAwake(true);
   }
   break;
 }
}

代码示例来源:origin: org.jbox2d/jbox2d-testbed

void Break() {
 // Create two bodies from one.
 Body body1 = m_piece1.getBody();
 Vec2 center = body1.getWorldCenter();
 body1.destroyFixture(m_piece2);
 m_piece2 = null;
 BodyDef bd = new BodyDef();
 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();
 Vec2 velocity1 = m_velocity.add(Vec2.cross(m_angularVelocity, center1.sub(center)));
 Vec2 velocity2 = m_velocity.add(Vec2.cross(m_angularVelocity, center2.sub(center)));
 body1.setAngularVelocity(m_angularVelocity);
 body1.setLinearVelocity(velocity1);
 body2.setAngularVelocity(m_angularVelocity);
 body2.setLinearVelocity(velocity2);
}

相关文章