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

0 favourites
  • 10 posts
From the Asset Store
Is a circular loading screen with code ready to use. No Animation.
  • 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)?

  • You can put json into array.

    action > array > (JSON) Download > input string.

    Then you can interpreter the array how you want.

  • 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).

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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)

  • 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

  • Thanks R0J0hound - that was exactly what I was looking for! Works like a charm now =)

  • R0J0hound - that is simply excellent! Thank you.

  • 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?

  • vubidugil

    link updated in original post

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)