I have the following setup:
- Room reloading is setup as per manual, and is working. If I paint tiles, it reflects in the running game without any issues.
- I created a function "create_collisions" which creates obj_collision instances for each solid tile.
- The function gets called in the create event of obj_make_collision
- I have placed one instance in the actual room and it does it's job without issues when I launch the game.
- After a few seconds the room reloads (even if I didn't make any changes) and all solid instances disappear.
- I tried to fix the problem by calling the function also in the room start event, but it didn't work.
- To further investigate, I put the function call into the Begin Step event, but it would not create any collision objects.
- I investigated further using show_debug_message and found the following:
- After reloading layer_get_id gives back a different value.
- layer_tilemap_get_id switches to giving back -1 upon the refresh, which means after reload I cannot get access to the the tilemap data anymore.
Here's my function for reference:
function create_collisions()
{
var _layer = layer_get_id("Tiles_1");
var _tileLayer = layer_tilemap_get_id(_layer);
show_debug_message(_layer);
var wt = tilemap_get_width(_tileLayer);
var ht = tilemap_get_height(_tileLayer);
for(var i = 0; i < wt; i++)
{
for(var j = 0; j < ht; j++)
{
var tile = tilemap_get(_tileLayer, i, j);
if(tile == 1)
{
instance_create_layer(i*32, j*32, "Instances", obj_collision);
}
}
}
}
I'd be happy to send a small test project.