• 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!

Legacy GM Can't get depth to work [SOLVED]

J

Jus

Guest
Hi all,

I have what seemed to be a simple question but I just can't get my depth to work. I understand the greater the depth value the further back it is, but one object keeps overlapping my other regardless of the depth value I set. Here's what I did:

I have two objects, one is a big text box and the other(s) is a sub text box. The big text box is like a frame that graphically contains the text, and it is also the control that spawns sub text boxes that draws out the text. Now I want the big text box to stay in front of the sub text boxes so I set the depth of the sub text boxes greater, which should send the text back. But it didn't. In fact, regardless of the depth values I set, the text always draw in front of my big text box.I have a feeling I'm missing something basic here... Please help, and thanks in advance!
 

jo-thijs

Member
Hi and welcome to the GMC!

In what events (if any) are you drawing the text boxes?
What are their default depths?
What code do you use to change depths?
What other relevant code do you have?
 
T

Tyrell D. Barnes

Guest
If you prefer to use the object method of drawing text boxes, then you need to be sure of two things:
  1. It is true that the larger the depth number, the further back it is; likewise, the more negative a number is, the further up it is. Ensure the order is correct, then move onto the next check.
  2. Drawing: GM:S brings several different Draw Events to the table; however, the normal Draw Event still applies here. If you placed them in different Draw Events, this may be where the problem lies, since a Draw Begin event will always be drawn before the Draw End event, for example. Check those just in case.
I prefer the easier method of drawing text boxes, which is having one object draw them. This way, it saves you the trouble of switching between two different objects, unless they both serve different purposes (as a general GUI to a textbox). You simply draw the larger box first, then draw the text box. The kind of Draw Event matters not here, as long as they are within the same Draw Event to begin with.
 
J

Jus

Guest
Hi and welcome to the GMC!

In what events (if any) are you drawing the text boxes?
What are their default depths?
What code do you use to change depths?
What other relevant code do you have?
I create the sub-text boxes in a step event, then in the sub-text boxes I use draw event to draw text.

I changed to default depth values to 0 (big box) and 20 (sub box). In fact, I tried different values and they all yield the same result: Text is always in front.

I also tried setting the values of depth in the Create event of both big and sub box. Still no effect.

The purpose of having a bigger text box is controlling where the text is drawn. Newest text appears from bottom, and the older ones scroll up. When the text eventually draws outside of the bigger box, it creates another scroll button that allows the user to scroll up to read older text. Other than that, there aren't any special codes.

And thanks for the warm welcome!


Edit: I found out problem: I was accidentally using the Draw GUI event! I switched to the normal Draw Event and it works fine now! Interesting to note that Draw GUI is always on top though.

Thanks all for the help!
 
Last edited by a moderator:
Top