GameMaker Can't display two layers at same time

for(j = 0; j < obj_grid.hard_y_limit; j++)
{
for(i = 0; i < obj_grid.hard_x_limit; i++)
{
temp = ds_grid_get(obj_place.collide_grid_tile, i, j);
temp1 = ds_grid_get(obj_place.danger_grid_tile, i, j);

tilemap_set("lyr_collide", temp, i, j);
tilemap_set("lyr_danger", temp1, i, j);
}
}

The code posted above is supposed to loop through a ds_grid and set the tilemap to that. But It seems only seems to take notice of the second map. If I comment out either line they both work, but not together.

If I change the second line to tilemap_set("lyr_danger", 1, 0, 0); The first line will work and the second line will set a specific tile in a specified place as stated and the whole thing 'works' fine.

I thought it may be overwriting somehow but this is not the case. Hence temp and temp 1 for the different map data.

Any advice once again most appreciated.
 
If this is the case then should it work at all? Edit: OK this actually worked.

Would you please explain why my previous code did not work. (It did but only for one line).

There may be some GMS2 black box things going on that I don't understand.

Thank you though.
 
Last edited:
I don't agree with doing things via name and prefer your method of using the ID. (That has fixed the problem mentioned above).

The problem I have is, if I create a new layer (even though the GMS GUI) I can't assign a new tileset to it unless it already had one assigned to it at startup, then I can assign whatever tileset I wish.

If you start the compile with no tileset assigned to the layer. You will never be able to as far as I can tell.

tilemap_tileset() does not work if there is no currently assigned tileset.

This is kind of a separate question but I mentioned it because I was trying to explain why I wasn't using ID's, it was because I couldn't do it from scratch, because of the problem stated above.

Thanks again.
 

meseta

Member
If this is the case then should it work at all? Edit: OK this actually worked.

Would you please explain why my previous code did not work. (It did but only for one line).

There may be some GMS2 black box things going on that I don't understand.

Thank you though.
Because it was expecting a numerical ID, the strings you gave it were evaluated as numbers. Strings in GM evaluate numerically to 0. So your code would have effectively been:

tilemap_set(0, temp, i, j);
tilemap_set(0, temp1, i, j);

Both lines would be setting tiles on ID 0, the second one overwrites the first.
 
Thanks. I managed to get this side of things working now. However, I am unable to perform 2 or more transformations at a time.

I can do:

lay_id = layer_tilemap_get_id("test");
tilemap_set(lay_id, tile_set_flip(1, true), 0, 0); // Flip, mirror or rotate

This works no problem, but as soon as I add a second transformation:

tilemap_set(lay_id, tile_set_flip(1, true), 0, 0);
tilemap_set(lay_id, tile_set_roate(1, true), 0, 0);

I only get the original orientation of the tile. If I use any transformations together I just get the original shape.
 

TheouAegis

Member
Because you aren't passing any new tile data.

The "1" in your code is supposed to be the tile data which you want to set the flag for. You just keep passing the same value, not the transformed value. If you are going to insist on using "1" for whatever reason, then do:

tilemap_set(lay_id, tile_set_rotate(tile_set_flip(1, true),true), 0, 0);

You need to read the manual and its examples more.
 
Because you aren't passing any new tile data.

The "1" in your code is supposed to be the tile data which you want to set the flag for. You just keep passing the same value, not the transformed value. If you are going to insist on using "1" for whatever reason, then do:

tilemap_set(lay_id, tile_set_rotate(tile_set_flip(1, true),true), 0, 0);

You need to read the manual and its examples more.
I was using "1" as an example I would be using a variable in my actual program.

I have gone over the manual many times. It's just one of those things that aren't clicking for me.

Partly because game maker allows you to do things that you shouldn't be able to do and thus makes it confusing.
 

TheouAegis

Member
My point still stands even if you're using a variable. You weren't passing the updated value, you were passing the original value both times.
 
I think I see what you mean now. I did not see at as overwriting because I thought mirror and flip etc where different flags stored separately. I'll play with this some more.

Edit: I have this working now. I don't know why I found this so hard. I totally get it now, I'm a very happy bunny.

Thanks for your help.
 
Last edited:
Top