GameMaker: Studio

GameMaker: Studio

View Stats:
Questions about the order of things being drawn.
So, I was working with draw_sprite, and I noticed some weird things happening. Do sprites always get drawn above the background, but below instances? So this is my understanding of how it is drawn, (i'm probably wrong)

Background
Sprites
Instances
GUI

Correct me if im wrong please!
Thank you!
< >
Showing 1-3 of 3 comments
An instance's draw event's timing is based on the depth given to it. The higher the number, the further back it is; this also applies to tile sets, but normally backgrounds set to the room will always be drawn first as part of the general canvas resetting that goes alongside drawing a background color. Instances with the same depth are usually handled in the order they're created, I believe.

As a general rule, a lot of people will give player objects a depth of -1 to keep them above everything else, and likewise assign negative values to their HUD objects and other things that decidedly always need to be in front (the GUI events are now ideal for this, always occuring after the normal Draw event, but are a pretty recent addition. Seperating something into the GUI drawing means depth priority is more or less reset; something with a depth of 0 in a Draw GUI event I believe still draws over something with a depth lower than that in the standard Draw cycle). Enemies, projectiles, and other such things tend to end up at depth 0 a lot, and the priority descends from there. depth can be changed at any time with a simple "depth = ___" plopped into your code somewhere, coming into effect the next time the draw event kicks in.
ahh ok, thanks!
so where do surfaces come in? surfaces and views are really boggling my mind right now.
If you create a surface in an instance that is the same depth as everything else, does the surfaces appear below all the other instance by default? Because that is certainly what it feels like is going on right now.
Anyway, no biggy and thanks for continuing to be so patient and helping me, you have no idea how fun you have made this for me haha
Surfaces are special. You're basically creating an extra canvas off-screen to draw on.

Instances execute their business in their defined order, more or less, so if you have one drawing to a surface it's going to do so the same way. Surfaces do not clear unless you tell them to, so things just keep getting drawn on top of what's there (if you want an active example of this, have a ball jump to your mouse cursor in an empty room where you've disabled "draw background color" and appreciate the motion trail). The advantage of a sruface is that you can draw its contents whenever you see fit, but this will only happen if you draw it manually. The timing is completely up to you in that sense, so take advantage of it.
< >
Showing 1-3 of 3 comments
Per page: 1530 50

Date Posted: May 16, 2014 @ 6:09pm
Posts: 3