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

Draw GUI and depths ?

DaveInDev

Member
Hi there,

Something is still not clear to me :
are the layers and depths also used by the Draw GUI events ?
I mean : are they always called in the same order as classic Draw events, respecting layers order or depths ? (but after all classic Draw events of course)
 
Last edited:

DaveInDev

Member
Not actually. When you change the depth of an instance you change its layer too. When a layer doesn't already exist with an instance's depth a new layer is created automatically.
Yes I confirm that's the way it works in 2.3 . Temporary layers are created for each new depth value, that's why the depth = -y strategy is not optimal anymore.

But my concern was not about depth and layers that I already understand, but with their influence on the GUI domain. And @obscene gave me the answer I was suspecting.
;)
 

Director_X

Member
Yes I confirm that's the way it works in 2.3 . Temporary layers are created for each new depth value, that's why the depth = -y strategy is not optimal anymore.
Depth is used to seperate objects when they share the same layer.
Sorry to deviate from the GUI optic, but just for your info, I have been using this layer logic and it has been working for me on the -y depth without any issues.

hmm.. drag-n-drop upload image in not working for some reason??
 
Last edited:

DaveInDev

Member
Sorry to deviate from the GUI optic, but just for your info, I have been using this layer logic and it has been working for me on the -y depth without any issues.

hmm.. cannot upload image for some reason??
Oh yes it's still working, but I understood that it was not optimal anymore because now, a temporary layer object is created/destructed for each new value of y that does not already have a corresponding layer. So if you have a lot of objects moving constantly from one depth to another, it's a lot of overhead I suppose.

See here :

or tutos like this one :
 

obscene

Member
I also use my own variation of the depth=-y, mostly in the create events of objects. Being that 99% of the instances in the room never move (only the characters, projectiles etc need to update their layer position when moving) I don't see any evidence of it being slow. I also create unique particle systems at every potential depth and again there is no issue. Possibly the act of creating those particle systems also causes GM to create layers, I don't know, but I can't detect any slowdown with or without their presence.
 

DaveInDev

Member
Yes I did not notice anything special too, but when you read other articles, some "experienced" people seem to talk about "issues" with "depth = -y" strategy . So I wonder what they are talking about...
 

DaveInDev

Member
Depth is more of a Z thing
but in 2D games
they use -y because say theres a tree in the middle of your screen now you want to be in front of it when lower on the screen
and you want too be behind it when higher on the screen, so you change the depth with the Y position on your screen
they actually are moving its depth or Z position if that makes sense
It is not the question of this topic. ;) We understand the depth concept.

We're just trying to understand why the "depth = -y" strategy is not recommanded anymore by some people since 2.3 and the introduction of layers and especially "temporary layers" created with each new depth value. Like @obscene said, it's probably not an issue if you do not have 1000 objects constantly changing their depth and creating/destroying these temp layers...

example :
 
Last edited:
Top