Recently, i have been trying to draw a very simple tileset for a grid-based game i started this year.
I write the game in Haxe with Heaps,
and draw the tiles in Aseprite.
My first issue was how to use the tileset with Heaps’s Atlas
class.
I draw each tile in a separate .aseprite
file,
mostly because i am going to animate some of them and animating the whole tileset is impractical,
but this is not a problem because i can use Aseprite’s command-line interface to generate a single PNG file with all the individual tiles packed in:
It generates something like the following image.
For now, every tile is a static 16 × 16 pixel image, but even so Aseprite most likely will place the tiles on the PNG in a non-predictable position, meaning that i can not know in advance the X and Y coordinates of any tile in the PNG.
To help with that, Aseprite also writes out a JSON-formatted file that has the names, coordinates, and sizes of each tile in the PNG:
Apparently, this format is a kind of de facto standard for spritesheets and Aseprite’s author is not sure where it came from,
possibly from TexturePacker.
Heaps’s Atlas
, on the other hand, uses a text file format based on libGDX,
also used by Spine,
and can not directly read Aseprite’s JSON files.
I did not find any tool to convert from Aseprite’s JSON to libGDX’s atlas format,
so i wrote one that serves my purposes.
By default, it reads the file from its standard input because, without the --data
parameter, Aseprite writes the JSON to its standard ouput,
therefore i can create both the PNG and the .atlas
files in a single line: