Java Code Examples for com.badlogic.gdx.physics.box2d.Fixture#getShape()
The following examples show how to use
com.badlogic.gdx.physics.box2d.Fixture#getShape() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RenderOfPolyFixture.java From tilt-game-android with MIT License | 6 votes |
public RenderOfPolyFixture(Fixture fixture, VertexBufferObjectManager pVBO) { super(fixture); PolygonShape fixtureShape = (PolygonShape) fixture.getShape(); int vSize = fixtureShape.getVertexCount(); float[] xPoints = new float[vSize]; float[] yPoints = new float[vSize]; Vector2 vertex = Vector2Pool.obtain(); for (int i = 0; i < fixtureShape.getVertexCount(); i++) { fixtureShape.getVertex(i, vertex); xPoints[i] = vertex.x * PhysicsConnector.PIXEL_TO_METER_RATIO_DEFAULT; yPoints[i] = vertex.y * PhysicsConnector.PIXEL_TO_METER_RATIO_DEFAULT; } Vector2Pool.recycle(vertex); mEntity = new PolyLine(0, 0, xPoints, yPoints, pVBO); }
Example 2
Source File: RenderOfCircleFixture.java From tilt-game-android with MIT License | 5 votes |
public RenderOfCircleFixture(Fixture fixture, VertexBufferObjectManager pVBO) { super(fixture); CircleShape fixtureShape = (CircleShape) fixture.getShape(); Vector2 position = fixtureShape.getPosition(); float radius = fixtureShape.getRadius() * PhysicsConnector.PIXEL_TO_METER_RATIO_DEFAULT; mEntity = new Ellipse(position.x * PhysicsConnector.PIXEL_TO_METER_RATIO_DEFAULT, position.y * PhysicsConnector.PIXEL_TO_METER_RATIO_DEFAULT, radius, radius, pVBO); }
Example 3
Source File: BuoyancyController.java From Codelabs with MIT License | 5 votes |
public void addBody(Fixture fixture) { try { PolygonShape polygon = (PolygonShape) fixture.getShape(); if (polygon.getVertexCount() > 2) { fixtures.add(fixture); } } catch (ClassCastException e) { Gdx.app.debug("BuoyancyController", "Fixture shape is not an instance of PolygonShape."); } }
Example 4
Source File: BuoyancyController.java From Codelabs with MIT License | 5 votes |
private List<Vector2> getFixtureVertices(Fixture fixture) { PolygonShape polygon = (PolygonShape) fixture.getShape(); int verticesCount = polygon.getVertexCount(); List<Vector2> vertices = new ArrayList<Vector2>(verticesCount); for (int i = 0; i < verticesCount; i++) { Vector2 vertex = new Vector2(); polygon.getVertex(i, vertex); vertices.add(new Vector2(fixture.getBody().getWorldPoint(vertex))); } return vertices; }