Hello Guest

Author Topic: Saving and Loading TileMaps  (Read 3865 times)

wagenheimer

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 50
    • View Profile
Saving and Loading TileMaps
« 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?


unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Saving and Loading TileMaps
« Reply #1 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.

rakkarage

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Saving and Loading TileMaps
« Reply #2 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

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Saving and Loading TileMaps
« Reply #3 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 :)

esdot

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: Saving and Loading TileMaps
« Reply #4 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,
« Last Edit: October 17, 2014, 01:46:01 am by esdot »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Saving and Loading TileMaps
« Reply #5 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.