List of usage examples for com.badlogic.gdx.physics.box2d Body isAwake
public boolean isAwake()
From source file:com.altportalgames.colorrain.utils.Box2DDebugRenderer.java
License:Apache License
private void renderBodies(World world) { for (Iterator<Body> iter = world.getBodies(); iter.hasNext();) { Body body = iter.next(); Transform transform = body.getTransform(); int len = body.getFixtureList().size(); List<Fixture> fixtures = body.getFixtureList(); for (int i = 0; i < len; i++) { Fixture fixture = fixtures.get(i); if (body.isActive() == false) 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/*from w w w.j a v a 2 s .c o m*/ drawShape(fixture, transform, SHAPE_AWAKE); } } for (Iterator<Joint> iter = world.getJoints(); iter.hasNext();) { Joint joint = iter.next(); drawJoint(joint); } int len = world.getContactList().size(); for (int i = 0; i < len; i++) drawContact(world.getContactList().get(i)); }
From source file:com.blindtigergames.werescrewed.debug.SBox2DDebugRenderer.java
License:Apache License
protected void renderBody(Body body) { Transform transform = body.getTransform(); int len = body.getFixtureList().size(); List<Fixture> fixtures = body.getFixtureList(); for (int i = 0; i < len; i++) { Fixture fixture = fixtures.get(i); if (drawBodies) { if (body.isActive() == false) 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/*from w w w. j av a 2s . co m*/ drawShape(fixture, transform, SHAPE_AWAKE); if (drawVelocities) { Vector2 position = body.getPosition(); drawSegment(position, body.getLinearVelocity().add(position), VELOCITY_COLOR); } } if (drawAABBs) { drawAABB(fixture, transform); } } }
From source file:com.me.mygdxgame.Entities.MydebugRenderer.java
License:Apache License
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/*from www.j a v a2s . co m*/ return SHAPE_AWAKE; }
From source file:com.stercore.code.net.dermetfan.utils.libgdx.box2d.Box2DUtils.java
License:Apache License
/** @param body the body for which to setup a new {@link BodyDef} * @return a new {@link BodyDef} instance that can be used to clone the given body */ public static BodyDef createDef(Body body) { BodyDef bodyDef = new BodyDef(); bodyDef.active = body.isActive();/* w ww.j a v a 2s . com*/ bodyDef.allowSleep = body.isSleepingAllowed(); bodyDef.angle = body.getAngle(); bodyDef.angularDamping = body.getAngularDamping(); bodyDef.angularVelocity = body.getAngularVelocity(); bodyDef.awake = body.isAwake(); bodyDef.bullet = body.isBullet(); bodyDef.fixedRotation = body.isFixedRotation(); bodyDef.gravityScale = body.getGravityScale(); bodyDef.linearDamping = body.getLinearDamping(); bodyDef.linearVelocity.set(body.getLinearVelocity()); bodyDef.position.set(body.getPosition()); bodyDef.type = body.getType(); return bodyDef; }
From source file:net.dermetfan.utils.libgdx.box2d.Box2DUtils.java
License:Apache License
/** creates a deep copy of a {@link Body} * @param body the {@link Body} to copy * @param shapes if the {@link Shape Shapes} of the {@link Fixture Fixures} of the given {@code body} should be {@link #copy(Shape) copied} as well * @return a deep copy of the given {@code body} */ public static Body copy(Body body, boolean shapes) { BodyDef bodyDef = new BodyDef(); bodyDef.active = body.isActive();//from w w w .j ava 2 s. c om bodyDef.allowSleep = body.isSleepingAllowed(); bodyDef.angle = body.getAngle(); bodyDef.angularDamping = body.getAngularDamping(); bodyDef.angularVelocity = body.getAngularVelocity(); bodyDef.awake = body.isAwake(); bodyDef.bullet = body.isBullet(); bodyDef.fixedRotation = body.isFixedRotation(); bodyDef.gravityScale = body.getGravityScale(); bodyDef.linearDamping = body.getLinearDamping(); bodyDef.linearVelocity.set(body.getLinearVelocity()); bodyDef.position.set(body.getPosition()); bodyDef.type = body.getType(); Body copy = body.getWorld().createBody(bodyDef); copy.setUserData(body.getUserData()); for (Fixture fixture : body.getFixtureList()) copy(fixture, copy, shapes); return copy; }
From source file:org.ams.physics.things.def.DefParser.java
License:Open Source License
public static void thingWithBodyToDefinition(ThingWithBody thingWithBody, ThingWithBodyDef def) { Body body = thingWithBody.getBody(); Fixture firstFixture = body.getFixtureList().first(); thingToDefinition(thingWithBody, def); def.active = body.isActive();//from w w w .j a v a 2s . c o m def.angle = body.getAngle(); def.angularDamping = body.getAngularDamping(); def.antiCollisionGroup = thingWithBody.getAntiCollisionGroup(); def.awake = body.isAwake(); def.bullet = body.isBullet(); def.categoryBits = firstFixture.getFilterData().categoryBits; def.density = firstFixture.getDensity(); def.fixedRotation = body.isFixedRotation(); def.friction = firstFixture.getFriction(); def.groupIndex = firstFixture.getFilterData().groupIndex; def.linearDamping = body.getLinearDamping(); def.maskBits = firstFixture.getFilterData().maskBits; def.position.set(body.getPosition()); def.restitution = firstFixture.getRestitution(); def.type = body.getType(); }
From source file:org.box2d.r3.gdx.GDXBox2DDebugRenderer.java
License:Apache License
private Color getColorByBody(final Body body) { if (body.isActive() == false) { return this.SHAPE_NOT_ACTIVE; } else if (body.getType() == BodyType.StaticBody) { return this.SHAPE_STATIC; } else if (body.getType() == BodyType.KinematicBody) { return this.SHAPE_KINEMATIC; } else if (body.isAwake() == false) { return this.SHAPE_NOT_AWAKE; } else {/*ww w. j a v a 2 s . c om*/ return this.SHAPE_AWAKE; } }
From source file:se.danielj.geometridestroyer.GeometriDestroyer.java
License:GNU General Public License
@Override public boolean touchDown(int screenX, int screenY, int pointer, int button) { if (!gameRunning) { return false; }//from ww w . j av a2 s . co m float x = ((float) screenX) / Gdx.graphics.getWidth() * Constants.WIDTH; float y = Constants.HEIGHT - ((float) screenY) / Gdx.graphics.getHeight() * Constants.HEIGHT; world.QueryAABB(new QueryCallback() { @Override public boolean reportFixture(Fixture fixture) { if (fixture.getBody().getUserData() instanceof Entity && ((Entity) fixture.getBody().getUserData()).isDestroyable()) { if (gameRunning) { world.destroyBody(fixture.getBody()); if (boxesLeft > 0) { --boxesLeft; } if (boxesLeft == 0) { victoryChecker = new VictoryChecker() { @Override public void check() { boolean sleeping = true; Iterator<Body> i = world.getBodies(); while (i.hasNext()) { Body body = i.next(); if (body.getUserData() instanceof Entity) { if (body.isAwake()) { sleeping = false; } } } if (sleeping) { victory(); } } }; } } } return false; } }, x, y, x, y); return false; }