List of usage examples for com.badlogic.gdx.physics.box2d Body destroyFixture
public void destroyFixture(Fixture fixture)
From source file:com.stercore.code.net.dermetfan.utils.libgdx.box2d.Box2DUtils.java
License:Apache License
/** {@link Body#destroyFixture(Fixture) destroys} all fixtures of the given body * @param body the body which fixtures to destroy */ public static void destroyFixtures(Body body) { Array<Fixture> fixtures = body.getFixtureList(); while (fixtures.size > 0) body.destroyFixture(fixtures.peek()); }
From source file:com.stercore.code.net.dermetfan.utils.libgdx.box2d.Box2DUtils.java
License:Apache License
/** {@link Body#destroyFixture(Fixture) destroys} all fixtures of the given body except the given ones * @param exclude the fixtures not to destroy * @param body the body which fixtures to destroy */ public static void destroyFixtures(Body body, Array<Fixture> exclude) { Array<Fixture> fixtures = body.getFixtureList(); for (int preserved = 0; preserved < fixtures.size;) { Fixture fixture = fixtures.get(fixtures.size - 1 - preserved); if (!exclude.contains(fixture, true)) body.destroyFixture(fixture); else/*from w ww. jav a 2s .c om*/ preserved++; } }
From source file:com.stercore.code.net.dermetfan.utils.libgdx.box2d.Box2DUtils.java
License:Apache License
/** @see #destroyFixtures(Body, Array) */ public static void destroyFixtures(Body body, Fixture... exclude) { Array<Fixture> fixtures = body.getFixtureList(); for (int preserved = 0; preserved < fixtures.size;) { Fixture fixture = fixtures.get(fixtures.size - 1 - preserved); if (!ArrayUtils.contains(exclude, fixture, true)) body.destroyFixture(fixture); else//from w w w.j av a 2 s . c o m preserved++; } }
From source file:com.stercore.code.net.dermetfan.utils.libgdx.box2d.Box2DUtils.java
License:Apache License
/** @see #destroyFixtures(Body, Array) */ public static void destroyFixtures(Body body, Fixture exclude) { Array<Fixture> fixtures = body.getFixtureList(); for (int preserved = 0; preserved < fixtures.size;) { Fixture fixture = fixtures.get(fixtures.size - 1 - preserved); if (fixture != exclude) body.destroyFixture(fixture); else//from www . j ava2 s . c o m preserved++; } }
From source file:me.scarlet.undertailor.collision.bbshapes.BoundingCircle.java
License:Open Source License
@Override public void applyFixture(Body body) { if (this.targetBody == body || !this.hasTarget()) { this.targetBody = body; if (lastFixture != null && body.getFixtureList().contains(lastFixture, true)) { body.destroyFixture(lastFixture); }/*from ww w .j a v a 2s .c o m*/ if (this.canCollide()) { body.setFixedRotation(fixedRotation); CircleShape circle = new CircleShape(); circle.setPosition(this.getOffset()); circle.setRadius(radius * this.getScale()); body.createFixture(circle, 0.5F); circle.dispose(); } } }
From source file:me.scarlet.undertailor.collision.bbshapes.BoundingCircle.java
License:Open Source License
@Override public void destroyFixture(Body body) { if (this.lastFixture != null && body.getFixtureList().contains(lastFixture, true)) { body.destroyFixture(lastFixture); this.lastFixture = null; }/*from w w w. j a v a 2 s. co m*/ }
From source file:me.scarlet.undertailor.collision.bbshapes.BoundingRectangle.java
License:Open Source License
@Override public void applyFixture(Body body) { if (this.targetBody == body || !this.hasTarget()) { this.targetBody = body; if (lastFixture != null && body.getFixtureList().contains(lastFixture, true)) { body.destroyFixture(lastFixture); }/*from ww w . j a v a 2 s. com*/ if (this.canCollide()) { Vector2 offset = this.getOffset(); PolygonShape polygon = new PolygonShape(); FixtureDef fixDef = new FixtureDef(); polygon.setAsBox((dimensions.x * this.getScale()) / 2, (dimensions.y * this.getScale()) / 2, new Vector2(offset.x * this.getScale(), offset.y * this.getScale()), this.getRotation()); fixDef.isSensor = this.isSensor(); fixDef.shape = polygon; fixDef.friction = 0.0F; fixDef.density = 1F; this.lastFixture = body.createFixture(fixDef); polygon.dispose(); } } else { throw new IllegalArgumentException("cannot reuse bounding object on another body"); } }
From source file:me.scarlet.undertailor.collision.bbshapes.BoundingRectangle.java
License:Open Source License
public void destroyFixture(Body body) { if (lastFixture != null && body.getFixtureList().contains(lastFixture, true)) { body.destroyFixture(lastFixture); this.lastFixture = null; }/* www.ja va 2 s.co m*/ }