2D Toolkit Forum
2D Toolkit => Support => Topic started by: wagenheimer on June 25, 2014, 08:59:25 pm
-
Hi!
I didn't found in editor how to Save/Load a Level using Tk2d TileMap!
Do I need to create a Scene for Each Level, or it's possible to load levels dynamically?
-
Create a scene for each level, its the most efficient way of loading things in and out.
-
that really seems like overkill... delete and recreate everything just to change a few tiles?
i got it working like suggested elsewhere on this board by just saving the tiles to string and loading from string. with the caveat that you have to set size to max and manage size yourself
i can provide a simple example code if want
https://github.com/jacobdufault/fullserializer
-
It isn't overkill if you care about load speed - the scene will load an order of magnitude or more faster. Each use case is different, use what works for you :)
-
Would it be possible to be a bit more direction on how to efficiently save and load Tilemaps?
We really want the ability to be able to build a scene and save it to disk as a text file. To be loaded later dynamically. We can serialize our own scene objects easily enough, but still not sure how to go about it with the Tilemaps.
Cheers,
-
You can use the tilemap API to get each tile (x and y) and write out the raw tile index for each of these. The tilemap is an array of 2D arrays (one for each layer), not much more.