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

SOLVED pause system with surfaces messes up sprite depth

S

Stratos.la

Guest
so yea! after u unpause the game a few of my other elements get behind others! i have it in the draw event but it doenst change if i use draw gui.
this is my draw event
GML:
draw_self();
if PAUSED
{
    
    if surface_exists(pausesrf)
    {
        draw_surface(pausesrf,0,0)
    }
    //////////
    draw_set_color(c_black)
    draw_set_alpha(0.5)
    draw_rectangle(0,0,room_width,room_height,0)
    draw_set_alpha(1)
}
else if !PAUSED
{
    if surface_exists(pausesrf)
    {surface_free(pausesrf)}
}
and my left pressed event
GML:
PAUSED = !PAUSED
if (PAUSED)
{   
    if !surface_exists(pausesrf)
        {
            pausesrf = surface_create(room_width,room_height);
            surface_copy(pausesrf,0,0,application_surface)
        }
    instance_deactivate_all(true)
    instance_create_depth(room_width/2,room_height/2,-100,obj_paused_menu)
}
else if (!PAUSED)
{
    instance_activate_all();
    if surface_exists(pausesrf)
    {surface_free(pausesrf)}
    instance_destroy(obj_paused_menu);   
}
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
If instances are on the same layer in the room editor, then there is no guarantee to the order in which they will be drawn. So, when you activate/deactivate instances, they may be activated in a different order to that in which they were created, which - if they are on the same layer - will affect the order in which they are drawn. Basically, if you want to ensure that some things are drawn over or under others then you must ensure that they are on different layers or depths.
 
Top