C
candlelight2007
Guest
I'm working on a simple "pause" feature where on a key pressed a snapshot of the current screen/room (using surface) would be shown with some stuff drawn on top ("game paused" message, etc.). Then on the "unpause" trigger, the surface would be released and the game would resume. All seems to be working great, except when the surface is released, I lose all control of all existing objects in the room. They become non responsive. I am new to surfaces, I admit, so to create one I followed the manual 's article on view_surface_id almost to the letter. Anyone can point me in the right direction?
Here are the snippets: I use obj_freeze object to control the actions. I commented out activate/deactivate statements to make debugging easier.
on Create:
-----------
On Key Pressed:
------------------
on Draw GUI:
--------
Here are the snippets: I use obj_freeze object to control the actions. I commented out activate/deactivate statements to make debugging easier.
on Create:
-----------
GML:
roomIsFrozen = false;
room_snapshot = -1; // surface we will be using to create a snapshot of the screen
------------------
GML:
if roomIsFrozen != true { //
roomIsFrozen = true; // freeze
if !surface_exists(room_snapshot) {
room_snapshot = surface_create(CAM_WIDTH, CAM_HEIGHT); // CAM_WIDTH and CAM _HEIGHT are macros I used for simplicity
view_surface_id[0] = room_snapshot;
}
// deactivate all layers except Settings layer
//instance_deactivate_all(true);
} else {
roomIsFrozen = false; // unfreeze
surface_free(room_snapshot);
// re-activate layers
//instance_activate_all();
}
on Draw GUI:
--------
GML:
if roomIsFrozen == true {
if surface_exists(room_snapshot) {
draw_surface_stretched(room_snapshot, 0, 0, CAM_WIDTH, CAM_HEIGHT)
}
// draw semitransparent veil
draw_set_alpha(0.5);
draw_set_color(c_dkgrey);
draw_rectangle(CAM_X, CAM_Y, CAM_X + CAM_WIDTH, CAM_Y + CAM_HEIGHT, false);
draw_set_alpha(1); // reset alpha
draw_set_colour(c_yellow);
draw_set_halign(fa_center);
draw_set_valign(fa_top);
//draw_text_transformed(CAM_CENTER_X, CAM_CENTER_Y, string("FROZEN") + "", 4, 4, 0);
draw_text_transformed(CAM_CENTER_X, CAM_CENTER_Y, string("FROZEN") + "", 4, 4, 0);
}