'Gamemaker Studio2, Draw GUI layer conflict

I would like to preface this by saying I am still quite new to gameMakerstudio and I do not know all there is to know about how the software works and this is probably the root cause of my problem as I do not know why I am having this current layering issue.

I have been having an issue where I have TWO DrawGUI events in separate objects within the same room.

The first object is a Fog Of War that draws a GUI and reveals the map as the player moves, and keeps explored places visible but not in view.

The second object is the joystick where a player will use their thumb to drag the stick to move the player.

Ever since I have implemented the Fog of War. I have been unable to view the joystick. It appears that the fog of war draws overtop of it and I am unable to use it.

I understand there are other draw events where I can do this.

Draw Draw GUI Draw Begin Draw End Draw GUI BEGIN Draw GUI END

After changing where I have the code drawing. Example: At first the joystick and the fog were both in Draw GUI, After moving one from Draw GUI to Draw GUI Begin, the same issue appears.

I have made sure to place the joystick at the top most level in the room and the fog of war at the bottom most layer.

I have tried to apply depth the object

oJoystick_Stick.depth = -100;

this does not achieve anything.

Is there another way to force two objects on the GUI layer to be on top of the other?



Solution 1:[1]

Some advice about DrawGUI

  • DrawGUI Begin --> call the event before every drawGUI in that moment
  • DrawGUI --------> the event is called sync with the screen refresh rate
  • DrawGUI End ----> call the event after every drawGUI in that moment

so GM-Studio "pipeline" for the DrawGUI is like the step event, we have a BEGIN, a CURRENT, an END.

To prioritize the object render, GM-Studio use the depth in-build variabile. Take the 0 as the reference value. Object with depth value > 0 are rendering as last. Object with depth value < 0 are rendering infront everything. Check the depth during the calling of the instance_create_depth() function, check where the depth variabile is changing, check in the room editor for each instance layer the depth value. and z-order.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Sansonight