C
Caique Assis
Guest
Hello! So, I tried today to make a little pause system with surfaces. The general idea is that if the game is paused, the application surface would be copied into a surface I created using the surface_copy function, and after that, I deactivate all instances. except my controller instance (where the surface code is running). The problem is, when I draw the surface, I only get a "blank surface". Here is my current code:
CREATE EVENT
STEP EVENT
DRAW EVENT
Yes, I'm making sure my controller object has the lowest depth, and it's the first instance being created in the room. I'm not using views or anything of the sort because this was just a simple test. I read somewhere that you need to use surface_copy in the draw event, but that didn't seem to work. I've already tested things without setting the surface target too, only setting it in the draw event, but didn't seem to work.
In my mind, simply copying the application_surface to my created surface would already do all of the job, without me needing to loop through all the instances and add their sprites to the surface.
Anyway, any help is appreciated. Thanks!
CREATE EVENT
Code:
pause = false;
surf = surface_create(room_width,room_height);
surface_set_target(surf);
draw_clear_alpha(c_black,0);
surface_reset_target();
Code:
if(keyboard_check_pressed(vk_enter)){
pause = !pause;
}
if(pause){
if(surface_exists(surf)){
surface_set_target(surf);
draw_clear_alpha(c_black,0);
surface_copy(surf,0,0,application_surface);
surface_reset_target();
}else{
surf = surface_create(room_width,room_height);
}
instance_deactivate_all(true);
}else{
if(surface_exists(surf)){
surface_free(surf);
}
instance_activate_all();
}
Code:
if(pause){
if(surface_exists(surf)){
surface_set_target(surf);
draw_clear_alpha(c_black,0);
draw_surface(surf,0,0);
surface_reset_target();
}else{
surf = surface_create(room_width,room_height);
surface_set_target(surf);
draw_clear_alpha(c_black,0);
surface_reset_target();
}
}
In my mind, simply copying the application_surface to my created surface would already do all of the job, without me needing to loop through all the instances and add their sprites to the surface.
Anyway, any help is appreciated. Thanks!