A couple of weeks ago I started looking for a 2D map editor that would help me create levels for the game engine. During my research one particular editor named Tiled kept showing up with great reviews, so I decided to check it out.
Tiled  is a free software which has been in development part-time for nearly 9 years. It receives regular updates and its latest version 1.0 was released just a few days ago. Its developer can be supported via his Patreon page .
Each of these formats have their pros and cons. The CSV format proposes a stripped-down version of the map containing only the definition of the tile layers. While more complex formats such as Json or XML include the metadata added via objects and properties. In my particular case, I’ll need the metadata but I don’t necessarily need all the properties that are included in a format like Json.
After investigating, I realized you can implement your own custom exporter for Tiled in a C++ or Python plugin as described here:
So, I decided to write my own plugin and here are the steps I followed:
- Set up the environment, it’s explained on the “Contributing to Tiled” page:
- Get the Tiled source code on GitHub:
- Download the Qt application framework:
- Check out one of the existing exporter plugins:
When you’re done building your plugin, get the DLL and copy it to the Tiled release folder with the rest of its plugin DLL. Now you just need to launch Tiled and activate the DLL in the editor’s options settings (if it’s not activated by default).
Also make sure you build your plugin with the same Qt version as the one used by the Tiled release. Tiled 1.0.0 is built with Qt 5.8.0. The version 5.9.0 was released just a few days ago so I ended up installing it and at first, I made the mistake of building my plugin with this version which made the plugin DLL incompatible with the release version of the editor.
The exporter format I implemented is called GMapText, it’s a CSV-like format containing the metadata that was missing for my needs. All being in a single file.
If you want to have a look at the implementation here’s the changelist on GitHub:
As an example, here’s what the XML looks like for the map in the previous screenshot:
Here’s what the Json looks like:
Finally, here’s what the GMapText looks like with this first implementation:
I’ll probably improve it in the future depending on the game engine needs.