G
Giang Gia Hùng
Guest
hey guys, I'm creating a Pause Menu for the game. While the game is pausing the string is still getting input and it's still drawing the text on the screen. Can someone explain to me why the instance_deactivate(all) doesn't work on this? (Here are the codes):
GML:
//o_Pause event Create
gameIsPaused = false;
allObjects[0,0] = noone;
//o_Pause event Key Press Escape
/// @description Pause the game
if(gameIsPaused == false) {
gameIsPaused = true;
var offset = 0;
for(var i = 0; i < instance_count; ++i) {
if(instance_find(all, i).sprite_index != -1) {
allObjects[i - offset, 0] = instance_find(all, i).sprite_index;
allObjects[i - offset, 1] = instance_find(all, i).image_index;
allObjects[i - offset, 2] = instance_find(all, i).x;
allObjects[i - offset, 3] = instance_find(all, i).y;
allObjects[i - offset, 4] = instance_find(all, i).image_xscale;
allObjects[i - offset, 5] = instance_find(all, i).image_yscale;
allObjects[i - offset, 6] = instance_find(all, i).image_angle;
allObjects[i - offset, 7] = instance_find(all, i).image_blend;
allObjects[i - offset, 8] = instance_find(all, i).image_alpha;
}
else
++offset;
}
instance_deactivate_all(true);
}
else {
instance_activate_all();
gameIsPaused = false;
allObjects = 0;
}
//o_Pause Draw event
/// @description While game is paused
if(gameIsPaused) {
draw_set_color(c_white);
draw_set_font(fnt_coders_crux);
draw_text(room_width/3, room_height/2, "GAME IS PAUSED");
for(var i = 0; i < array_height_2d(allObjects); ++i) {
draw_sprite_ext(allObjects[i, 0], allObjects[i, 1], allObjects[i, 2],
allObjects[i, 3], allObjects[i, 4], allObjects[i, 5], allObjects[i, 6],
allObjects[i, 7], allObjects[i, 8] / 2);
}
}
// o_Textbox Step event
/// @description Handle Keys Presses/Input
if(o_Pause.gameIsPaused == false)
if(keyboard_check(vk_anykey) and string_length(text) < 15)
{
if(keyboard_string >= chr(97) && keyboard_string <= chr(122))
text = text + string(keyboard_string);
keyboard_string = "";
}
// o_Textbox Draw event
/// @description Draw the Text
draw_self();
draw_set_color(c_white);
draw_set_halign(fa_left);
draw_set_valign(fa_middle);
draw_set_font(fnt_coders_crux);
draw_text(x+7,y+20,text+cursor);