SOLVED How does the layer_set_visible() work?

Petrik33

Member
Hello everybody, I have recently posted that I don't understand why is my background grey when I turn into the illustrations mode, making the layers invisible and deactivating all instance before that. But I have just found out that my layers are not turning invisible. SO why doesn't this work?:

GML:
layer_set_visible("Background",false);
layer_set_visible("Tiles",false);
layer_set_visible("Trees",false);
So, if you wonder how it looks, I've attached screenshot:

And also, I have tried making this alternatively which also doesn't work and outputs this into log: "layer_set_visible() - could not find specified layer in current room"
Code to achieve this error:
GML:
var _background = layer_background_get_id("Background");
var _tiles = layer_tilemap_get_id("Tiles");
var _trees = layer_background_get_id("Trees");
layer_set_visible(_background,false);
layer_set_visible(_tiles,false);
layer_set_visible(_trees,false);
And the output on the screen is totally same by the way. Help me please. I just can't understand why doesn't it work
 

Attachments

Last edited:

Petrik33

Member
If you're using deprecated depth variable, then this won't work. Otherwise - it should.
Unfortunately it doesn't. Seems like I can have some mistakes elsewhere in code, but I don't touch the layers anywhere else, so it's weird!
 

ThraxxMedia

Member
Please try with your second approach again, but instead of using layer_background_get_id() or layer_tilemap_get_id(), just use layer_get_id() instead.

Reason: layer_background_get_id() doesn't actually get the ID of the layer itself, but of the background element on a layer.
Same with layer_tilemap_get_id() - this gets the ID of the tilemap element on the layer, not the layer ID itself.

Also, but this pretty much goes without saying: please see if the layers you want to hide actually exist (names might be case-sensitive, I'm not sure).
 

Petrik33

Member
Please try with your second approach again, but instead of using layer_background_get_id() or layer_tilemap_get_id(), just use layer_get_id() instead.

Reason: layer_background_get_id() doesn't actually get the ID of the layer itself, but of the background element on a layer.
Same with layer_tilemap_get_id() - this gets the ID of the tilemap element on the layer, not the layer ID itself.

Also, but this pretty much goes without saying: please see if the layers you want to hide actually exist (names might be case-sensitive, I'm not sure).
Hey man, much time has gone since you've recomended me to do it. But I have passed this problem until later, and just now I have tried doing what you suggested me. And... Big Thank YOU! It helped, Although it's quite upsetting how tiny was the mistake)
 
Top