#Creating A Pause Menu

4 messages · Page 1 of 1 (latest)

eternal smelt
#

I followed a tutorial to create a pretty advanced pause menu that takes a snapshot of the game and then freezes all instances. However, I wanted to add the line of code instance_activate_object(obj_pauseobject); in order for a menu screen to pop up during the pause. I haven't got that to work and was wondering what I would have to do in order for it to activate. Here is my code in the Post Draw, where pause_surf and pause_surf_buffer = -1:

gpu_set_blendenable(false);
if (pause) //draw frozen image
{
surface_set_target(application_surface);
if (surface_exists(pause_surf)) draw_surface(pause_surf,0,0);
else
{
pause_surf = surface_create(resW,resH);
buffer_set_surface(pause_surf_buffer,pause_surf,0);
}
surface_reset_target();
}

if (keyboard_check_pressed(vk_escape)) // toggle pause
{
if (!pause) // pause now
{
pause = true;

    instance_activate_object(obj_pauseobject);
    
    instance_deactivate_all(true); //deactive all except this instance
    
        
    pause_surf = surface_create(resW,resH); // capture game moment except draw gui
    surface_set_target(pause_surf);
        draw_surface(application_surface,0,0);
    surface_reset_target();
    
    if (buffer_exists(pause_surf_buffer)) buffer_delete(pause_surf_buffer)
    pause_surf_buffer = buffer_create(resW * resH * 4, buffer_fixed, 1);
    buffer_get_surface(pause_surf_buffer, pause_surf, 0);
    
    

}
else //unpause
{
    pause = false;
    instance_activate_all();
    instance_deactivate_object(obj_pauseobject);
    if (surface_exists(pause_surf)) surface_free(pause_surf);
    //if (buffer_exists(pause_surf_buffer)) buffer_delete(pause_surface_buffer);
    
}

}

gpu_set_blendenable(true);

pine heart
#

as soon as you activate the object (underneath pause = true), you immediately deactivate all the instances (including obj_pauseobject)

#

try swapping the lines instance_active_object and instance_deactivate_all

eternal smelt
#

Hmm that didn't seem to work either