use of test.AtlasWriter.Rect in project ultimate-java by pantinor.
the class SpriteAtlasTool method makeAtlas.
public void makeAtlas() {
Settings settings = new Settings();
AtlasWriter mrp = new AtlasWriter(settings);
Collections.sort(gridItems);
ArrayList<Rect> packedRects = new ArrayList<>();
String last = null;
int idx = 0;
for (MyListItem it : gridItems) {
Rect rect = new Rect(it.x * dim, it.y * dim, dim, dim);
rect.name = it.name;
if (rect.name.equals(last)) {
idx++;
} else {
idx = 0;
}
rect.index = idx;
packedRects.add(rect);
last = rect.name;
}
System.out.println("Writing: number of sprites: " + packedRects.size());
try {
mrp.writePackFileWithRects(new File("."), "sprites-atlas.txt", packedRects, "assets/tilemaps/latest.png");
} catch (IOException e) {
e.printStackTrace();
}
System.out.println("done");
}
Aggregations