How do I create a level editor for my game?

  • So, the question I have is much more specific than the title would lead you to believe.

    I was hoping to have a game where possible arena layouts would be pulled from an array of size n, m, 2. Where n is the number of layout from which one would be selected, and m is the max number of blocks with positions saved.

    Then, in the actual game, an x (layout) would be chosen. And from that each Y of the array would have an x and y position saved listing where a block should be placed.

    I've struggled to explain this effectively but hopefully that makes sense.

    One possible level could look like this:

    https://imgur.com/a/1DejG

    I built a level editor (for me, not players) so I can drop blocks in, and have their positions saved in an array before downloading said array as JSON. That is how I generated the above.

    My question is how do I then, once I have my JSON file of levels, move this back into Construct2 so in the player's version of the game the array is prebuilt and ready to be used?

    I'm happy to link the capx but currently it is just the level editor I've briefly discussed so probably isn't all that necessary.

    Thank you,

    Jordan

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • If you have one JSON string for the entire array (all levels) you can simply hard-code it in your events.

    You'll need to replace quote marks (") with 3 consecutive quote marks (""") everywhere in JSON string.

    Then you just do this:

    Array load from JSON "{"""c2array""":true,"""size""": ...........

    Or you can save JSON string in text file, import into your project, request with AJAX, load to the array.

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