Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String jsonText = loadJson();
- JsonValue root = new JsonReader().parse(jsonText).getChild("rigidbodies");
- float originX = root.get("origin").getFloat("x") * scale;// * texture.getWidth();
- float originY = root.get("origin").getFloat("y") * scale;// * texture.getWidth();
- origin = new Vector2(originX, originY);
- for (JsonValue polygon = root.getChild("polygons"); polygon != null; polygon = polygon.next())
- {
- float[] indices = new float[polygon.size * 2];
- int indiceCount = 0;
- for (JsonValue vertex = polygon.child; vertex != null; vertex = vertex.next())
- {
- indices[indiceCount] = vertex.getFloat("x") * (texture.getWidth() * scale);
- indices[indiceCount + 1] = vertex.getFloat("y") * (texture.getWidth() * scale);
- }
- polygons.add(new Polygon(indices));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement