Search in sources :

Example 1 with Rect

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");
}
Also used : Rect(test.AtlasWriter.Rect) ArrayList(java.util.ArrayList) IOException(java.io.IOException) File(java.io.File) Settings(com.badlogic.gdx.tools.texturepacker.TexturePacker.Settings)

Aggregations

Settings (com.badlogic.gdx.tools.texturepacker.TexturePacker.Settings)1 File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Rect (test.AtlasWriter.Rect)1