Created
February 15, 2014 01:37
-
-
Save Tom-Ski/9013168 to your computer and use it in GitHub Desktop.
maximtwo is my hero
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected void loadFixtures(TiledMap map, World world) { | |
MapLayer fixturesLayer = map.getLayers().get("fixtures"); | |
Array<PolylineMapObject> fixtures = fixturesLayer.getObjects().getByType(PolylineMapObject.class); | |
BodyDef bd = new BodyDef(); | |
bd.type = BodyType.StaticBody; | |
groundBody = world.createBody(bd); | |
groundBody.setUserData(-1); | |
FixtureDef fd = new FixtureDef(); | |
fd.density = 1.0f; | |
fd.friction = 0.3f; | |
fd.filter.categoryBits = ContactFilters.BOUNDARY; | |
fd.filter.maskBits = (short) (ContactFilters.PLAYER | ContactFilters.POTATO | ContactFilters.CRATE); | |
for(int i = 0; i < fixtures.size; ++i) { | |
ChainShape cs = new ChainShape(); | |
fd.shape = cs; | |
Polyline fixture = fixtures.get(i).getPolyline(); | |
float[] vertices = fixture.getTransformedVertices(); | |
for(int j = 0; j < vertices.length; ++j) { | |
vertices[j] /= PIXELS_PER_METER; | |
} | |
cs.createChain(vertices); | |
groundBody.createFixture(fd); | |
cs.dispose(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment