At the moment I have two different ways of loading tilemaps, one is by reading in a .tmx file exported from Tiled with the native libGDX class TmxMapLoader
like so:
tiledMap = new TmxMapLoader().load("tilemap/moontilemap.tmx");
And another way is by creating a 2D array and putting in tile IDs in there, then saving that to a JSON file, like this:
public static void saveMap(String id, String name, int[][][] map) {
CustomMapData mapData = new CustomMapData();
mapData.id = id;
mapData.name = name;
mapData.map = map;
Gdx.files.local("maps/").file().mkdirs();
FileHandle file = Gdx.files.local("maps/" + id + ".map");
file.writeString(json.prettyPrint(mapData), false);
}
Ideally I'd like to combine these, but I'm not sure how to. I want to continue using Tiled to create my initial tilemaps and save them in .tmx files, but I want the player to edit the maps and then alter the data in the .tmx file to save these changes. How do I go about this?