Tilemap as data

#1

Hi there!

I would like to use a tilemap as data in the game, something like a sequence for each level. I have successfully implemented this by adding a tilemap to a gameobject, one gameobject per level loaded dinamically via factory.load.

The init method of the controller attached to the game object parse the tilemap and generate a table with the sequence, then it delete the gameobject.

However this method requires that I create the gameobject, in particular the texture used by the tilemap is loaded in videomemory and soon later destroyed.

So, my question is: is there a way to access the tilemap WITHOUT creating the gameobject?

I guess I may use an external tilemap editor to export a lua file with a table for each level. But I would prefer to stay within the Defold editor.

Thank a lot for any help! and thanks for Defold!

0 Likes

#2

No, that is not possible. But what if you kept the tilesource for the tilemap very very small?

You could maybe use an editor extension script to parse the tilemap and output JSON or some other data format on pre build.

0 Likes

#3

Many thanks for your help!

I will try to use an editor extension script. But at the moment I don’t understand how to read the tilemap nor how to write a lua file with the data from such a script.

Thanks!

0 Likes