Load a tilemap(SOLVED)

Hello,

I have a game that’s similar to Pac-man, where you fill in a tilemap. This tilemap is a game object component and the game object is added to a collection.
Once the level is complete, I want to load a new tilemap.
Do I just have a bunch of game objects, with levels attached to each one and swap them in and out as required.
Or can I load a new tilemap into my current game object? I was trying to do this with “sys.load_resource” but didn’t get anywhere. Or trying to change the game object component value to the next tilemap.

Hope that makes sense :slight_smile:

Thanks,

David

You cannot load resources like that using sys.load_resource(). sys.load_resource() is for loading custom data that you’ve added to your binary. It could be images, level data or something else. You have two options:

  1. Create multiple collections, each one containing a game object with a tilemap containing a level and load/unload the collections based on which level the player plays
  2. Have one collection with a game object and a tilemap and modify the tilemap contents using tilemap.set_tile(). The level data could be loaded using sys.load_respource() and perhaps stored as json (decode using json.decode()), or you could have the level definitions in a Lua module.
1 Like

Great thanks. I’ll try option 2 I think :+1::sunglasses: