List of usage examples for com.badlogic.gdx.physics.box2d Body setAngularDamping
public void setAngularDamping(float angularDamping)
From source file:com.strategames.engine.gameobject.types.Balloon.java
License:Open Source License
@Override protected void setupBody(Body body) { /**/*from w ww . ja v a 2 s . c om*/ * TODO do we really need a separate loader for each object? Replace with static? */ BodyEditorLoader loader = new BodyEditorLoader(Gdx.files.internal("fixtures/balloon.json")); loader.setupVertices("Balloon", WIDTH); //Balloon body body.setAngularDamping(1f); body.setLinearDamping(1f); FixtureDef fixtureBalloon = new FixtureDef(); fixtureBalloon.density = 0.1786f; // Helium density 0.1786 g/l == 0.1786 kg/m3 fixtureBalloon.friction = 0.6f; fixtureBalloon.restitution = 0.4f; // Make it bounce a little bit loader.attachFixture(body, "Balloon", 0, fixtureBalloon); this.upwardLiftPosition = body.getLocalCenter(); this.upwardLiftPosition.y += 0.1f; this.upwardLift = -body.getMass() * this.liftFactor; }
From source file:io.piotrjastrzebski.sfg.game.objects.PickupDebris.java
License:Open Source License
private Body createBody(World world, int id) { final BodyDef obstacleBodyDef = new BodyDef(); obstacleBodyDef.type = BodyDef.BodyType.DynamicBody; final Body body = world.createBody(obstacleBodyDef); // large dampening so tiny bodies dont explode super fast body.setLinearDamping(0.75f);//from w ww . j a v a 2 s . c om body.setAngularDamping(0.75f); final PolygonShape rect = new PolygonShape(); rect.setAsBox(WIDTHS[id], HEIGHTS[id]); final FixtureDef fixtureDef = new FixtureDef(); fixtureDef.shape = rect; fixtureDef.density = 3f; fixtureDef.friction = 0.25f; fixtureDef.restitution = 0.25f; fixtureDef.filter.categoryBits = Collision.BODY_PART; fixtureDef.filter.maskBits = Collision.MASK_BODY_PART; body.createFixture(fixtureDef); // Clean up rect.dispose(); return body; }
From source file:io.piotrjastrzebski.sfg.game.objects.PlayerRagDoll.java
License:Open Source License
private Body createBody(World world, int id, float scale) { final BodyDef obstacleBodyDef = new BodyDef(); obstacleBodyDef.type = BodyDef.BodyType.DynamicBody; final Body body = world.createBody(obstacleBodyDef); // large dampening so tiny bodies dont explode super fast body.setLinearDamping(0.75f);/*from ww w . j a v a 2s. co m*/ body.setAngularDamping(0.75f); final PolygonShape rect = new PolygonShape(); rect.setAsBox(WIDTHS[id] * scale, HEIGHTS[id] * scale); final FixtureDef fixtureDef = new FixtureDef(); fixtureDef.shape = rect; fixtureDef.density = 3f; fixtureDef.friction = 0.25f; fixtureDef.restitution = 0.25f; fixtureDef.filter.categoryBits = Collision.BODY_PART; fixtureDef.filter.maskBits = Collision.MASK_BODY_PART; // without this bodies are actually lower than expected when driven by animation body.setGravityScale(0); body.createFixture(fixtureDef); // Clean up rect.dispose(); return body; }
From source file:rosthouse.rosty.systems.PhysicsSystem.java
public <T extends Shape> PhysicsComponent<T> createPhysicsComponent(BodyDef.BodyType type, T shape, Vector2 position, FixtureDef fixture) { fixture.shape = shape;/*w w w. j a va 2s . co m*/ bodyDef.position.set(position); Body body = world.createBody(bodyDef); body.setLinearDamping(0.1f); body.setAngularDamping(0.1f); body.setType(type); return new PhysicsComponent<>(shape, body.createFixture(fixture)); }
From source file:rosthouse.rosty.systems.PhysicsSystem.java
public <T extends Shape> SensorComponent<T> createSensorComponent(BodyDef.BodyType type, T shape, Vector2 position, FixtureDef fixture) { fixture.shape = shape;//from ww w . ja v a2 s . c o m fixture.isSensor = true; bodyDef.position.set(position); Body body = world.createBody(bodyDef); body.setLinearDamping(0.1f); body.setAngularDamping(0.1f); body.setType(type); return new SensorComponent<>(shape, body.createFixture(fixture)); }