2D Toolkit Forum

2D Toolkit => Support => Topic started by: wagenheimer on June 25, 2014, 08:59:25 pm

Title: Saving and Loading TileMaps
Post 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?

Title: Re: Saving and Loading TileMaps
Post by: unikronsoftware on June 25, 2014, 10:02:38 pm
Create a scene for each level, its the most efficient way of loading things in and out.
Title: Re: Saving and Loading TileMaps
Post by: rakkarage on June 27, 2014, 04:26:55 pm
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
Title: Re: Saving and Loading TileMaps
Post by: unikronsoftware on June 27, 2014, 04:32:26 pm
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 :)
Title: Re: Saving and Loading TileMaps
Post by: esdot on October 17, 2014, 01:42:19 am
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,
Title: Re: Saving and Loading TileMaps
Post by: unikronsoftware on October 18, 2014, 08:48:33 am
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.