[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
14
S
3
G
1
Posts: 77
Reputation: 1,035

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: 142
Reputation: 3,262

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
14
S
3
G
1
Posts: 77
Reputation: 1,035

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: 142
Reputation: 3,262

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
14
S
3
G
1
Posts: 77
Reputation: 1,035

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://www.dropbox.com/s/w7b6tjsawhdbp ... .capx?dl=1
/examples31/tilesJSON_convert.capx
Last edited by R0J0hound on Mon Sep 11, 2017 10:10 pm, edited 1 time in total.
B
92
S
32
G
107
Posts: 5,274
Reputation: 69,959

Post » Tue Dec 15, 2015 11:38 am

Thanks @R0J0hound - that was exactly what I was looking for! Works like a charm now =)
B
14
S
3
G
1
Posts: 77
Reputation: 1,035

Post » Sat Jan 23, 2016 3:55 pm

@R0J0hound - that is simply excellent! Thank you.
A big fan of JavaScript.
B
74
S
20
G
69
Posts: 2,207
Reputation: 43,836

Post » Wed Aug 30, 2017 7:46 am

R0J0hound wrote: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


@R0J0hound
Please, you could restore the download link?
B
18
S
4
Posts: 52
Reputation: 1,096

Post » Mon Sep 11, 2017 10:10 pm

@vubidugil
link updated in original post
B
92
S
32
G
107
Posts: 5,274
Reputation: 69,959


Return to How do I....?

Who is online

Users browsing this forum: Solomon and 12 guests