Wow...that level editor was awesome .
Hey, programmer for Stealth2D here Thank you, glad you like it!
Thought would be nice to share the code logics with you guys here. These were used to accomplish import/export:
- Dictionary & Array objects
- FileChooser with some CSS editing
The tiles seen here which are the building-blocks of your level, are actually just 1 single Sprite object with multiple frames representing different tiles. The animation speed is then set to 0. With the condition for comparing frames, I could get hold of these tiles for data use.
Since the grid sizes are 128x128, all placed tiles are in the coordinate of (origin.X*128, origin.Y*128). With that said, I could easily store them in arrays according to their individual origins. For the Z depth of the Array, 0= tile.frame, 1=rotation, 2=flip. For flip it is just 0 or 1 which works in conjunction to a boolean.
For each tile placed, a storing function is triggered which includes storing the tiles to an Array, then parse the Array JSON string into Dictionary and then finally store Dictionary JSON string into local storage. This is how the save works. As for loading files, it's just reversing the order starting with a given JSON string of the Dictionary (which is also the exported file), then extract that Array from the Dictionary, then finally spawn tiles accordingly. The surprising part was, IT'S SO FAST! All these happen in split seconds and I'm really happy with the results.
As for loading the PLAY, it's the same but this time the tiles are replaced with objects, each with their functions in the game. That's it! Two layouts was used only, with 17 event sheets used and loads of codes (especially functions) and you get Stealth2D!
Also, not to mention the names for each tiles are actually stored in the Dictionary JSON file created in C3! Which I found out that the HTML5 export did not include it and I had to manually add a global string that contain the JSON string of the tile names.