List of usage examples for com.badlogic.gdx.physics.box2d Body isBullet
public boolean isBullet()
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();//from w w w . j a v a2 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(); return bodyDef; }
From source file:edu.lehigh.cse.lol.Actor.java
License:Open Source License
/** * Change the size of an actor, and/or change its position * * @param x The new X coordinate of its bottom left corner * @param y The new Y coordinate of its bototm left corner * @param width The new width of the actor * @param height The new height of the actor *//* w w w.jav a 2 s .co m*/ public void resize(float x, float y, float width, float height) { // To scale a polygon, we'll need a scaling factor, so we can // manually scale each point float xscale = height / mSize.y; float yscale = width / mSize.x; // set new height and width mSize.x = width; mSize.y = height; // read old body information Body oldBody = mBody; // make a new body if (mIsCircleBody) { Fixture oldFix = oldBody.getFixtureList().get(0); setCirclePhysics(oldFix.getDensity(), oldFix.getRestitution(), oldFix.getFriction(), oldBody.getType(), oldBody.isBullet(), x, y, (width > height) ? width / 2 : height / 2); } else if (mIsBoxBody) { Fixture oldFix = oldBody.getFixtureList().get(0); setBoxPhysics(oldFix.getDensity(), oldFix.getRestitution(), oldFix.getFriction(), oldBody.getType(), oldBody.isBullet(), x, y); } else if (mIsPolygonBody) { Fixture oldFix = oldBody.getFixtureList().get(0); // we need to manually scale all the vertices PolygonShape ps = (PolygonShape) oldFix.getShape(); float[] verts = new float[ps.getVertexCount() * 2]; for (int i = 0; i < ps.getVertexCount(); ++i) { ps.getVertex(i, mTmpVert); verts[2 * i] = mTmpVert.x * xscale; verts[2 * i + 1] = mTmpVert.y * yscale; } setPolygonPhysics(oldFix.getDensity(), oldFix.getRestitution(), oldFix.getFriction(), oldBody.getType(), oldBody.isBullet(), x, y, verts); } // clone forces mBody.setAngularVelocity(oldBody.getAngularVelocity()); mBody.setTransform(mBody.getPosition(), oldBody.getAngle()); mBody.setGravityScale(oldBody.getGravityScale()); mBody.setLinearDamping(oldBody.getLinearDamping()); mBody.setLinearVelocity(oldBody.getLinearVelocity()); // disable the old body oldBody.setActive(false); }
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 a v a 2s . c o m*/ 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();//ww w . j a v a 2 s . c om 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(); }