List of usage examples for com.badlogic.gdx.physics.box2d Body isSleepingAllowed
public boolean isSleepingAllowed()
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 .ja v a2 s . 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(); 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 ww w .java 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; }