• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

[SOLVED] Changing depth and using instance_deactivate_layer?

D

DarklinkFighter

Guest
Hi,

I encountered an issue with my game after I tried to change the way my pausing works...

Previously I created a screenshot sprite and deactivated all Instances but reactivated some controller objects...
Now I tried to implement an Inventory and for that I refactored it to instance_deactivate_layer but it seems not to work...

I found out in the debuger that many but not all of my instances have a layer of -1 (because I use depth = -y for some objects)...
After that I red in the "depth" manual:
IMPORTANT! When you modify the depth variable and GameMaker STudio 2 manages the layers, the built in layer variable will return -1 and not the layer ID, since managed layers cannot be manipulated through code.
Does this mean the instance_deactivate_layer does not work anymore for these objects?
If so... How could I fix this?
 

Joe Ellis

Member
hmm I'd try and actually exit the level, saving everything like you would if you saved the game, go to the inventory with the still screenshot of the game in the background, then reload it when you exit the inventory, it'd be tricky to do but I think that would be the best solution, cus your basically telling it to pause part of the game while another thing runs, and theres no thing to do that by default

But with the question you were asking yeah, once you modify the depth of an object it wont return the layer id, so it wont deactivate it (I imagine, I'm not suree)
 
Last edited:
That's right, as soon as you start using the depth variable, the layer will return -1.

One solution would be that you could put all the controller objects id's and anything you want to be kept active when paused in a ds_list or array.

Then you deactivate all instances, then reactivate the instances in the array only.
 
Top