A tool for optimising png tilesheets in ltdk projects
Did you ever want to remove all duplicate tiles from a png without destroying your tilemaps in ldtk?
Me too, so I made this small script.
You tell it where the ldtk project is and which tilesheet to remove duplicates from. It will create a new tilesheet png and remap all the tiles to the new positions in all layers and levels where that tilesheet is used.
Install with
haxelib git ldtk-crush https://github.com/jobf/ldtk-crush
Then run it as follows.
haxelib run ldtk-crush
It needs some arguments in order to process. These will be explained in the command line if missing. Below is a complete example.
Do not use absolute paths.
haxelib run ldtk-crush tests/resources/mapdata.ldtk Tilesheet outpath
Or if you want to determine the width of the resulting png you can specify it, for example 128 pixels.
haxelib run ldtk-crush tests/resources/mapdata.ldtk Tilesheet outpath 128
These arguments are in order
- path-to-project (the path to the ldtk file to be processed)
- tilesheet-identifier (the name of the tilesheet to be processed)
- destination-directory (the directory to put the resulting files)
- png-width, optional (the width in pixels of the resulting tilesheet png)
I've tested it with my most recent project and it's working nicely. However I put this together quickly over a couple of afternoons so there may be bugs. Please backup your input files before using it.
If you need changes or extra functionality please make an issue or pull request.