/** Destroy a rigid body given a definition. No reference to the definition is retained. This function is locked during * callbacks. * @warning This automatically deletes all associated shapes and joints. * @warning This function is locked during callbacks. */ public void destroyBody (Body body) { JointEdge jointEdge = body.body.getJointList(); while (jointEdge != null) { JointEdge next = jointEdge.next; world.destroyJoint(jointEdge.joint); joints.remove(jointEdge.joint); jointEdge = next; } world.destroyBody(body.body); bodies.remove(body.body); for (Fixture fixture : body.fixtures) { fixtures.remove(fixture.fixture); } }
void DestroyBody() { for (int i = 0; i < e_maxBodies; ++i) { if (m_bodies[i] != null) { getWorld().destroyBody(m_bodies[i]); m_bodies[i] = null; return; } } }
void DestroyBody() { for (int i = 0; i < e_maxBodies; ++i) { if (m_bodies[i] != null) { getWorld().destroyBody(m_bodies[i]); m_bodies[i] = null; return; } } }
void DestroyBody() { for (int i = 0; i < k_maxBodies; ++i) { if (m_bodies[i] != null) { getWorld().destroyBody(m_bodies[i]); m_bodies[i] = null; return; } } }
@Override public void keyPressed(char key, int argKeyCode) { switch (key) { case 'b': for (int i = 0; i < 4; ++i) { if (m_bodies[i] != null) { getWorld().destroyBody(m_bodies[i]); m_bodies[i] = null; break; } } break; case 'j': for (int i = 0; i < 8; ++i) { if (m_joints[i] != null) { getWorld().destroyJoint(m_joints[i]); m_joints[i] = null; break; } } break; } }
getWorld().destroyBody(b);
void Create(int index) { if (m_bodies[m_bodyIndex] != null) { getWorld().destroyBody(m_bodies[m_bodyIndex]); m_bodies[m_bodyIndex] = null;
@Override public void keyPressed(char argKeyChar, int argKeyCode) { switch (argKeyChar) { case ',': if (m_bullet != null) { getWorld().destroyBody(m_bullet); m_bullet = null; } { CircleShape shape = new CircleShape(); shape.m_radius = 0.25f; FixtureDef fd = new FixtureDef(); fd.shape = shape; fd.density = 20.0f; fd.restitution = 0.05f; BodyDef bd = new BodyDef(); bd.type = BodyType.DYNAMIC; bd.bullet = true; bd.position.set(-31.0f, 5.0f); m_bullet = getWorld().createBody(bd); m_bullet.createFixture(fd); m_bullet.setLinearVelocity(new Vec2(400.0f, 0.0f)); } break; } }
void Create(int index) { if (m_bodies[m_bodyIndex] != null) { getWorld().destroyBody(m_bodies[m_bodyIndex]); m_bodies[m_bodyIndex] = null; } BodyDef bd = new BodyDef(); float x = MathUtils.randomFloat(-10.0f, 10.0f); float y = MathUtils.randomFloat(10.0f, 20.0f); bd.position.set(x, y); bd.angle = MathUtils.randomFloat(-MathUtils.PI, MathUtils.PI); bd.type = BodyType.DYNAMIC; if (index == 4) { bd.angularDamping = 0.02f; } m_bodies[m_bodyIndex] = getWorld().createBody(bd); if (index < 4) { FixtureDef fd = new FixtureDef(); fd.shape = m_polygons[index]; fd.friction = 0.3f; fd.density = 20.0f; m_bodies[m_bodyIndex].createFixture(fd); } else { FixtureDef fd = new FixtureDef(); fd.shape = m_circle; fd.friction = 0.3f; fd.density = 20.0f; m_bodies[m_bodyIndex].createFixture(fd); } m_bodyIndex = (m_bodyIndex + 1) % e_maxBodies; }
void DestroyBody() { for (int i = 0; i < e_maxBodies; ++i) { if (m_bodies[i] != null) { getWorld().destroyBody(m_bodies[i]); m_bodies[i] = null; return; } } }
void DestroyBody() { for (int i = 0; i < k_maxBodies; ++i) { if (m_bodies[i] != null) { getWorld().destroyBody(m_bodies[i]); m_bodies[i] = null; return; } } }
void DestroyBody() { for (int i = 0; i < e_maxBodies; ++i) { if (m_bodies[i] != null) { getWorld().destroyBody(m_bodies[i]); m_bodies[i] = null; return; } } }
private void launchBomb(Vec2 position, Vec2 velocity) { if (bomb != null) { m_world.destroyBody(bomb); bomb = null; } // todo optimize this BodyDef bd = new BodyDef(); bd.type = BodyType.DYNAMIC; bd.position.set(position); bd.bullet = true; bomb = m_world.createBody(bd); bomb.setLinearVelocity(velocity); CircleShape circle = new CircleShape(); circle.m_radius = 0.3f; FixtureDef fd = new FixtureDef(); fd.shape = circle; fd.density = 20f; fd.restitution = 0; Vec2 minV = new Vec2(position); Vec2 maxV = new Vec2(position); minV.subLocal(new Vec2(.3f, .3f)); maxV.addLocal(new Vec2(.3f, .3f)); aabb.lowerBound.set(minV); aabb.upperBound.set(maxV); bomb.createFixture(fd); }
Body gameObjectInstanceRemovedFromScene(GameObjectInstance aInstance) { Body theSimulatedBody = dynamicObjects.remove(aInstance); aInstance.positionProperty().removeChangeListener(positionChangeListener); if (theSimulatedBody == null) { theSimulatedBody = staticObjects.remove(aInstance); } if (theSimulatedBody != null) { physicsWorld.destroyBody(theSimulatedBody); return theSimulatedBody; } return null; }
@Override public void keyPressed(char key, int argKeyCode) { switch (key) { case 'b': for (int i = 0; i < 4; ++i) { if (m_bodies[i] != null) { getWorld().destroyBody(m_bodies[i]); m_bodies[i] = null; break; } } break; case 'j': for (int i = 0; i < 8; ++i) { if (m_joints[i] != null) { getWorld().destroyJoint(m_joints[i]); m_joints[i] = null; break; } } break; } }
getWorld().destroyBody(b);
void Create(int index) { if (m_bodies[m_bodyIndex] != null) { getWorld().destroyBody(m_bodies[m_bodyIndex]); m_bodies[m_bodyIndex] = null; } BodyDef bd = new BodyDef(); float x = (float) Math.random() * 20 - 10; float y = (float) Math.random() * 20; bd.position.set(x, y); bd.angle = (float) Math.random() * MathUtils.TWOPI - MathUtils.PI; m_userData[m_bodyIndex] = index; bd.userData = m_userData[m_bodyIndex]; if (index == 4) { bd.angularDamping = 0.02f; } m_bodies[m_bodyIndex] = getWorld().createBody(bd); if (index < 4) { FixtureDef fd = new FixtureDef(); fd.shape = m_polygons[index]; fd.friction = 0.3f; m_bodies[m_bodyIndex].createFixture(fd); } else { FixtureDef fd = new FixtureDef(); fd.shape = m_circle; fd.friction = 0.3f; m_bodies[m_bodyIndex].createFixture(fd); } m_bodyIndex = (m_bodyIndex + 1) % e_maxBodies; }
@Override public void keyPressed(char argKeyChar, int argKeyCode) { switch (argKeyChar) { case ',': if (m_bullet != null) { getWorld().destroyBody(m_bullet); m_bullet = null; } { CircleShape shape = new CircleShape(); shape.m_radius = 0.25f; FixtureDef fd = new FixtureDef(); fd.shape = shape; fd.density = 20.0f; fd.restitution = 0.05f; BodyDef bd = new BodyDef(); bd.type = BodyType.DYNAMIC; bd.bullet = true; bd.position.set(-31.0f, 5.0f); m_bullet = getWorld().createBody(bd); m_bullet.createFixture(fd); m_bullet.setLinearVelocity(new Vec2(400.0f, 0.0f)); } break; } }
void Create(int index) { if (m_bodies[m_bodyIndex] != null) { getWorld().destroyBody(m_bodies[m_bodyIndex]); m_bodies[m_bodyIndex] = null; } BodyDef bd = new BodyDef(); float x = MathUtils.randomFloat(-10.0f, 10.0f); float y = MathUtils.randomFloat(10.0f, 20.0f); bd.position.set(x, y); bd.angle = MathUtils.randomFloat(-MathUtils.PI, MathUtils.PI); bd.type = BodyType.DYNAMIC; if (index == 4) { bd.angularDamping = 0.02f; } m_bodies[m_bodyIndex] = getWorld().createBody(bd); if (index < 4) { FixtureDef fd = new FixtureDef(); fd.shape = m_polygons[index]; fd.friction = 0.3f; fd.density = 20.0f; m_bodies[m_bodyIndex].createFixture(fd); } else { FixtureDef fd = new FixtureDef(); fd.shape = m_circle; fd.friction = 0.3f; fd.density = 20.0f; m_bodies[m_bodyIndex].createFixture(fd); } m_bodyIndex = (m_bodyIndex + 1) % e_maxBodies; }
public synchronized void launchBomb(Vec2 position, Vec2 velocity) { if (bomb != null) { m_world.destroyBody(bomb); bomb = null; } // todo optimize this BodyDef bd = new BodyDef(); bd.type = BodyType.DYNAMIC; bd.position.set(position); bd.bullet = true; bomb = m_world.createBody(bd); bomb.setLinearVelocity(velocity); CircleShape circle = new CircleShape(); circle.m_radius = 0.3f; FixtureDef fd = new FixtureDef(); fd.shape = circle; fd.density = 20f; fd.restitution = 0; Vec2 minV = new Vec2(position); Vec2 maxV = new Vec2(position); minV.subLocal(new Vec2(.3f, .3f)); maxV.addLocal(new Vec2(.3f, .3f)); aabb.lowerBound.set(minV); aabb.upperBound.set(maxV); bomb.createFixture(fd); }