Install Steam
login
|
language
简体中文 (Simplified Chinese)
繁體中文 (Traditional Chinese)
日本語 (Japanese)
한국어 (Korean)
ไทย (Thai)
Български (Bulgarian)
Čeština (Czech)
Dansk (Danish)
Deutsch (German)
Español - España (Spanish - Spain)
Español - Latinoamérica (Spanish - Latin America)
Ελληνικά (Greek)
Français (French)
Italiano (Italian)
Bahasa Indonesia (Indonesian)
Magyar (Hungarian)
Nederlands (Dutch)
Norsk (Norwegian)
Polski (Polish)
Português (Portuguese - Portugal)
Português - Brasil (Portuguese - Brazil)
Română (Romanian)
Русский (Russian)
Suomi (Finnish)
Svenska (Swedish)
Türkçe (Turkish)
Tiếng Việt (Vietnamese)
Українська (Ukrainian)
Report a translation problem
So far as I can tell the childs depth setting will always override that of the parent. By default an objects depth starts at 0 so even if you assign it as a child of a parent with a depth higher or lower than 0 it will end up being 0.
In my case with parent / child depth, I had issues when trying to have a child instance draw text to the screen. The parents depth was set to -1 but the childs was still at the default 0 so my text kept getting covered up by other stuff drawn at a -1 depth. I had to set all the children of that object to -1 and even took the extra step of temporarily making the childs depth -100 long enough to draw the text to screen and then setting it back to -1 as this ensured that my text was always on top.
If you want the child object to inherit the parent's depth, you'll need to manually set the depth in the parent's Create Event (or a different event, depending on the situation).
That thought hadn't occured to me!
I knew the children inherited the parents events, unless overidden, but I didn't even think of setting the depth in any of the parents events.
This is why I like reading and posting in these forums. I always learn something even if its minor.
Hmm... I just had a situation where I ended up needing to rework my objects depths and it was a pain going through and manually changing them all so I figured I'd do it like you said here so it would inherit it from the parent.
Unforunately, it still doesn't work. I set the depth on the parent both in the depth box and with a line of code in the Creave event, but any children that are created don't inherit the parents depth despite the fact that they are inheriting the parents create event where depth is being set.
Am I doing something wrong here?
UPDATE - The answer is "Yes!" ... I am doing something wrong. I forget the "-" when I set the depth in the creave event of the parent. <coughs> So when its set correctly it works correctly... who'd have thought...
self.depth = parentDepth;
I ran into the issue myself a few minutes ago, reading here that the child would override the parent, i tried setting the child to a blank value. Which Game Maker set back to zero. (Thanks Game Make!) anyway, I just created the piece of code above and slapped it in the parent objects creator function. On all children I'm running inherit, so this works great for me.
(for anyone looking for this in the future! :) )