Search in sources :

Example 1 with Shape

use of com.badlogic.gdx.physics.box2d.Shape in project commons-gdx by gemserk.

the class Box2dUtils method translateFixtures.

/**
	 * Internally translates all the Body's fixtures the specified translation, without moving the Body's center. For now, it generates garbage so should be used only once.
	 * 
	 * @param body
	 *            The body to work on.
	 * @param tx
	 *            The translation in x coordinate.
	 * @param ty
	 *            The translation in y coordinate.
	 */
public static void translateFixtures(ArrayList<Fixture> fixtures, float tx, float ty) {
    // TODO: should be in a Box2dUtils
    for (int i = 0; i < fixtures.size(); i++) {
        Fixture fixture = fixtures.get(i);
        Shape shape = fixture.getShape();
        if (shape.getType() == Type.Polygon)
            ShapeUtils.translatePolygonShape((PolygonShape) shape, tx, ty);
        else if (shape.getType() == Type.Circle)
            ShapeUtils.translateCircleShape((CircleShape) shape, tx, ty);
    }
}
Also used : PolygonShape(com.badlogic.gdx.physics.box2d.PolygonShape) Shape(com.badlogic.gdx.physics.box2d.Shape) CircleShape(com.badlogic.gdx.physics.box2d.CircleShape) PolygonShape(com.badlogic.gdx.physics.box2d.PolygonShape) Fixture(com.badlogic.gdx.physics.box2d.Fixture)

Example 2 with Shape

use of com.badlogic.gdx.physics.box2d.Shape in project commons-gdx by gemserk.

the class FixtureDefBuilder method circleShape.

public FixtureDefBuilder circleShape(float radius) {
    Shape shape = new CircleShape();
    shape.setRadius(radius);
    fixtureDef.shape = shape;
    return this;
}
Also used : Shape(com.badlogic.gdx.physics.box2d.Shape) CircleShape(com.badlogic.gdx.physics.box2d.CircleShape) PolygonShape(com.badlogic.gdx.physics.box2d.PolygonShape) CircleShape(com.badlogic.gdx.physics.box2d.CircleShape)

Aggregations

CircleShape (com.badlogic.gdx.physics.box2d.CircleShape)2 PolygonShape (com.badlogic.gdx.physics.box2d.PolygonShape)2 Shape (com.badlogic.gdx.physics.box2d.Shape)2 Fixture (com.badlogic.gdx.physics.box2d.Fixture)1