Loading TMX/Tiled-Exported JSON Into a Game

Discussion and feedback on Construct 2

Post » Fri Jan 17, 2014 5:08 am

What I want to do is be able to load TMX files and/or the JSON files generated by the map editor Tiled into C2.

However, I need this to be done by loading from my website.

I'm a bit confused by the process, and information regarding loading tilemaps is incredibly vague, let alone on how the current JSON importer works with the tilemap plugin. I saw mention but once about loading TMX files into C2, but there was no mention of whether or not this could be done during, say, gameplay.

What would be even better is if I could load the JSON files generated by the Tiled exporter, as the file size is cut to about a quarter of the TMX size.

Is there any native functionality of C2 to load these files? If not, how would I go about loading and parsing the JSON files created by Tiled? It seems pretty straightforward, but I have little experience writing parsers.

I found a few other tutorials with similar content, and one for parsing the XML of Tiled's TMX file, but nothing about handling JSON.

Can anyone help?
ImageImageImageImage
B
62
S
19
G
51
Posts: 633
Reputation: 30,826

Post » Fri Jan 17, 2014 11:11 am

It's difficult to load TMX files at runtime because the TMX format uses a variety of different compression schemes, some of which are tricky to get working in a browser.

The editor can import TMX, and then you can use the TilesJSON expression at runtime to get the tile data in JSON format which you can later load at runtime.
Scirra Founder
B
397
S
236
G
88
Posts: 24,423
Reputation: 194,560

Post » Fri Jan 17, 2014 5:00 pm

I did note the compression schemes. Tiled has an option to use uncompressed XML, which I was considering, but it takes up more data than it needs to, hence why I said it was taking up relatively more space than their JSON export.

There is a tutorial explaining how to import Tiled's TMX XML maps at runtime, and I am hoping to get down one type of file. XML would work for now, I just can't think of how to get started.

However, I do need to do all this without preloading anything through the editor.
ImageImageImageImage
B
62
S
19
G
51
Posts: 633
Reputation: 30,826


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 12 guests