[SOLVED] Load C2 generated JSON array into Tilemap in Editor

Get help using Construct 2

Post » Tue Dec 08, 2015 11:53 am

Hi all!

I've been working on a level editor, which can save & load levels in runtime in json format. However, today I realized that one can only load tilemap from TMX files in the C2 editor view.

Is there a way to load C2 generated JSON string to populate a tilemap object already in the editor view?
Alternatively, is there a way to export (save) the tilemap as TMX JSON format during runtime in C2 (so that it would be later possible to open in the editor view)?
Last edited by striimix on Tue Dec 15, 2015 11:42 am, edited 1 time in total.
B
13
S
3
G
1
Posts: 71
Reputation: 998

Post » Tue Dec 08, 2015 11:59 am

You can put json into array.
action > array > (JSON) Download > input string.
Then you can interpreter the array how you want.
B
23
S
5
G
4
Posts: 141
Reputation: 3,260

Post » Tue Dec 08, 2015 1:09 pm

Rexu wrote:You can put json into array.
action > array > (JSON) Download > input string.
Then you can interpreter the array how you want.

Thanks for your response, but my problem/question is how do you get the tiles to display inside the Construct 2 editor?

I already have loading and saving working perfectly during runtime. What I would like to see, is to load the tiles into the tilemap object already in the editor view of Construct 2 (and not from TMX file but from a json (for example, Tilemap.AsJSON string generated in C2).
B
13
S
3
G
1
Posts: 71
Reputation: 998

Post » Tue Dec 08, 2015 4:06 pm

I'm not sure if that's possible. You should seek for a third party plugin or something like this, but even plugins don't work this way. For editing purposes you can print image of your tilemap while in runtime then overlay it in editor.
B
23
S
5
G
4
Posts: 141
Reputation: 3,260

Post » Mon Dec 14, 2015 9:02 pm

Thanks for the suggestion. For my needs it would be important to simply get the tiles loaded on different layouts from the json created by C2 rather than TMX created on Tiled, so that the levels could be expaned with objects etc. The reason why levels are created with C2 made level editor instead of the editor view of Construct2 is because I wanted to have an easy to use editor to create the overall levels and be able to test the gameplay on runtime right away. However, leaving levels as plain as that would make them a bit boring and repetitive in the long run - coding object placements and such on the other hand would make the level editor bloated and not so easy to use.

@Ashley is there any chance of getting possibility of exporting tilemaps in the TMX format in runtime from C2 or alternatively loading tilesheet from JSON already in the editor view of Construct 2 (currently we can only do that during runtime, which works perfectly but sadly the editor does not remember the loaded tilemap in the editor view after testing)
B
13
S
3
G
1
Posts: 71
Reputation: 998

Post » Tue Dec 15, 2015 6:39 am

You could do it by manually editing the layout's xml file. Under the tilemap instance there is a block called "tilemap-data" that stores the tilemap's tiles.

Now what the tilemap's tilemap.tilesJSON expression gives is compressed with rle, and the ordering is a bit different.

Here's a utility that you can use to convert it to be usable in the xml.
https://dl.dropboxusercontent.com/u/542 ... nvert.capx
B
91
S
31
G
98
Posts: 5,192
Reputation: 65,170

Post » Tue Dec 15, 2015 11:38 am

Thanks @R0J0hound - that was exactly what I was looking for! Works like a charm now =)
B
13
S
3
G
1
Posts: 71
Reputation: 998

Post » Sat Jan 23, 2016 3:55 pm

@R0J0hound - that is simply excellent! Thank you.
I only occasionally visit - I'm learning C# for Unity, but c2 is still a respectable game engine imo....
B
71
S
18
G
65
Posts: 2,196
Reputation: 41,527


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 6 guests