kl76947 Posted April 23, 2014 Share Posted April 23, 2014 Let's say I created a tilemap using game.add.tilemap(). Are there any helper functions where I can Export the map as json, so I can re-use and reload it next time? Link to comment Share on other sites More sharing options...
Heppell08 Posted April 23, 2014 Share Posted April 23, 2014 Use TILED as a map editor to export the JSON file for the map. http://www.mapeditor.org/ Link to comment Share on other sites More sharing options...
stvrbbns Posted March 6, 2016 Share Posted March 6, 2016 Is there a real answer to this question? What is the best way to save/export a Phaser.TileMap as JSON to be reloaded/reinstantiated later? As of 2.4.6 - Baerlon, the public methods do not appear to contain built-in functionality for this. Phaser's accepted tile map formats (Phaser.Tilemap.CSV or Phaser.Tilemap.TILED_JSON) aren't particularly well documented themselves. I assume that the latter is "the Tiled JSON format" (based on the TMX format), but I have not figured out what the CSV format actually is. Looking at the examples (e.g. catastrophi_level1.csv), "CSV" looks to be nothing more than a map of tile integer IDs - no objects, collision data, layers, etc. That pretty much necessitates any *useful* Phaser TileMap save/export to result in the TILED_JSON format. Link to comment Share on other sites More sharing options...
stvrbbns Posted March 7, 2016 Share Posted March 7, 2016 I've gotten this far: tileMapLayer_to_CSV = function (layer) { var csv = ''; for (var y = 0; y < layer.data.length; y++) { if (y > 0) { csv += '\n'; } for (var x = 0; x < layer.data[y].length; x++) { if (x > 0) { csv += ','; } csv += layer.data[y][x].index; } } return csv; }; // end tileMapLayer_to_CSV() Link to comment Share on other sites More sharing options...
Recommended Posts