List of usage examples for com.badlogic.gdx.physics.box2d Fixture setFriction
public void setFriction(float friction)
From source file:com.tnf.ptm.entities.planet.TileObjBuilder.java
License:Apache License
private Body buildBody(PtmGame game, float toPlanetRelAngle, float dist, Tile tile, Planet planet, float spriteSz) { BodyDef def = new BodyDef(); def.type = BodyDef.BodyType.KinematicBody; float toPlanetAngle = planet.getAngle() + toPlanetRelAngle; PtmMath.fromAl(def.position, toPlanetAngle, dist, true); def.position.add(planet.getPos());/* ww w . j a v a 2s . c o m*/ def.angle = (toPlanetAngle + 90) * PtmMath.degRad; def.angularDamping = 0; Body body = game.getObjMan().getWorld().createBody(def); ChainShape shape = new ChainShape(); List<Vector2> points = new ArrayList<Vector2>(); for (Vector2 curr : tile.points) { Vector2 v = new Vector2(curr); v.scl(spriteSz); points.add(v); } Vector2[] v = points.toArray(new Vector2[] {}); shape.createLoop(v); Fixture f = body.createFixture(shape, 0); f.setFriction(Const.FRICTION); shape.dispose(); return body; }
From source file:edu.lehigh.cse.lol.Actor.java
License:Open Source License
/** * Adjust the default physics settings (density, elasticity, friction) for * this actor/*from w ww . ja va 2s. c o m*/ * * @param density New density of the actor * @param elasticity New elasticity of the actor * @param friction New friction of the actor */ public Actor setPhysics(float density, float elasticity, float friction) { for (Fixture f : mBody.getFixtureList()) { f.setDensity(density); f.setRestitution(elasticity); f.setFriction(friction); } mBody.resetMassData(); return this; }
From source file:org.ams.physics.things.AbstractThingWithBody.java
License:Open Source License
@Override public void setFriction(float friction) { fixtureDef.friction = friction;/* www . j a va 2 s .com*/ if (body != null) { for (Fixture fixture : body.getFixtureList()) { fixture.setFriction(friction); } } }
From source file:org.catrobat.catroid.physics.PhysicsObject.java
License:Open Source License
public void setFriction(float friction) { if (friction < MIN_FRICTION) { friction = MIN_FRICTION;/*from w ww. j av a2 s. c o m*/ } if (friction > MAX_FRICTION) { friction = MAX_FRICTION; } fixtureDef.friction = friction; for (Fixture fixture : body.getFixtureList()) { fixture.setFriction(friction); } }
From source file:org.destinationsol.game.planet.TileObjBuilder.java
License:Apache License
private Body buildBody(SolGame game, float toPlanetRelAngle, float dist, Tile tile, Planet planet, float spriteSz) { BodyDef def = new BodyDef(); def.type = BodyDef.BodyType.KinematicBody; float toPlanetAngle = planet.getAngle() + toPlanetRelAngle; SolMath.fromAl(def.position, toPlanetAngle, dist, true); def.position.add(planet.getPos());//from w ww.j a va 2 s .co m def.angle = (toPlanetAngle + 90) * SolMath.degRad; def.angularDamping = 0; Body body = game.getObjMan().getWorld().createBody(def); ChainShape shape = new ChainShape(); List<Vector2> points = new ArrayList<Vector2>(); for (Vector2 curr : tile.points) { Vector2 v = new Vector2(curr); v.scl(spriteSz); points.add(v); } Vector2[] v = points.toArray(new Vector2[] {}); shape.createLoop(v); Fixture f = body.createFixture(shape, 0); f.setFriction(Const.FRICTION); shape.dispose(); return body; }