Sprite Draw Order - Depth

N

NoFontNL

Guest
So, I have an object A (depth = -2) and it draws itself in the draw event:
draw_sprite_ext(sprite_index,image_index,x,y+yoffset,image_xscale,image_yscale,image_angle,c_white,1);

Then I have another object, object B (depth = -4) drawing this in the draw event:
draw_set_color(c_black);
draw_rectangle(view_xview-32,bbox_bottom+64+1,view_xview+view_wview+32,view_yview+view_hview+32,false);

Now, the object with a depth of -2 (object A) draws the sprite ON TOP of the drawn rectangle by object B.

What's going wrong here?
 

TailBit

Member
You could try to have them draw their depth value, just to check if it could have been changed by some other source?
 
N

NoFontNL

Guest
The depth stays the same. Also, there is object C. It has the same depth as object A, but it only draws itself on top of object B if object B is created after object C.
 

TailBit

Member
This is odd, the only thing I can think it could be is that one of them have a old version loaded into memory where the depth value is different .. it should be possible to solve like so:
help file said:
Clean Build: This is the same as clicking the green "broom" icon in the main IDE toolbar, and will clear the asset compiler cache. This is important as it prevents any "stale" assets from corrupting your game. It is not necessary to clear the cache every build, but should you be getting any odd errors or corrupted sprites, it should be done, and it should always be done before building any final packages for deployment.
 
I tested your code, works correctly for me.

Then again, I'm using GMS 2, it looks like you are using GMS 1.4, am I right?

What event are you using to set the depth? Just checking, as setting the depth in the draw event doesn't work.

Do you have any other custom drawing systems implemented, like some controller object that also draws everything using a with() statement by any chance. Because that would cause the drawing order to be messed up in the way you describe unless you are controlling the draw order yourself.
 
N

NoFontNL

Guest
I set the depth in the object itself in the IDE. And the sprites get drawn by the object itself in the draw event.
 
Top