Legacy GM Problem with pause screen menu

L

LordScrat

Guest
This is my first ever thread in this forum, I hope I don't screw this up.

So my pause screen does work properly and all, but I have a problem with the menu buttons displaying (Example http://gph.is/2tfI3Ad ). So as you can see in the example, there are slightly bigger buttons displaying, and I don't know why. Also they are kinda static, if I move far enough I won't see them anymore, but they shouldn't be there in the first place. The menu also works fine.

Here are my pause objects (They're all visible, the obj_pause_buttons all inherit from par_pause_button, and obj_pause is persistent):

obj_pause:

Create:

/// Initialize pause
pause = false;
p_resume = obj_pause_button_resume;
p_menu = obj_pause_button_menu;
p_exit = obj_pause_button_exit;
p_cursor = obj_pause_cursor;

Draw GUI:

if(pause) {
instance_deactivate_all(true);

var vx = view_wport[0] + view_xport[0];
var vy = view_hport[0] + view_yport[0];

// Title
draw_set_font(fnt_title);
draw_text(vx / 2 /*+ font_get_size(fnt_title)*/, vy / 4, "Game Paused");

instance_activate_object(p_resume);
p_resume.x = vx / 2;
p_resume.y = vy / 4 + 100;

instance_activate_object(p_menu);
p_menu.x = vx / 2;
p_menu.y = vy / 4 + 200;

instance_activate_object(p_exit);
p_exit.x = vx / 2;
p_exit.y = vy / 4 + 300;

instance_activate_object(p_cursor);

} else {
instance_destroy(p_resume);

instance_destroy(p_menu);

instance_destroy(p_exit);

instance_destroy(p_cursor);

instance_activate_all();
}

Press P-key:

if(room != rm_menu) {
pause = true;

//var vx = view_wport[0] + view_xport[0];
//var vy = view_hport[0] + view_yport[0];
var vx = view_xview[0] + view_wview[0] / 2;
var vy = view_yview[0] + view_hview[0] / 2;

// Create buttons and cursor
if(!instance_exists(p_resume))
p_resume = instance_create(0, 0, obj_pause_button_resume);

if(!instance_exists(p_menu))
p_menu = instance_create(0, 0, obj_pause_button_menu);

if(!instance_exists(p_exit))
p_exit = instance_create(0, 0, obj_pause_button_exit);

if(!instance_exists(p_cursor))
p_cursor = instance_create(0, 0, obj_pause_cursor);
}

obj_pause_cursor (the black hollow rectangle):

Create:

/// Initialize Cursor
selected_button = obj_pause_button_resume;

Step:

/// Selecting Button
var u_key = keyboard_check_pressed(vk_up) || keyboard_check_pressed(ord('W'));
var d_key = keyboard_check_pressed(vk_down) || keyboard_check_pressed(ord('S'));
var s_key = keyboard_check_released(vk_space) || keyboard_check_released(vk_enter);

if(s_key)
script_execute(selected_button.button_action);

if(u_key)
if(selected_button == obj_pause_button_resume)
selected_button = obj_pause_button_exit;
else if(selected_button == obj_pause_button_menu)
selected_button = obj_pause_button_resume;
else
selected_button = obj_pause_button_menu;

if(d_key)
if(selected_button == obj_pause_button_resume)
selected_button = obj_pause_button_menu;
else if(selected_button == obj_pause_button_menu)
selected_button = obj_pause_button_exit;
else
selected_button = obj_pause_button_resume;

x = selected_button.x;
y = selected_button.y;

Draw GUI:

draw_self();

par_pause_button:

Create:

/// Initialize Button
button_text = "";
button_action = scr_resume_game;

Draw GUI:

/// Draw Button and Text
draw_self();
draw_set_colour(c_black);
draw_set_font(fnt_pause);
draw_set_halign(fa_center);
draw_set_valign(fa_middle);
draw_text(x, y, button_text);

All the obj_pause_buttons simply have the text which you see in the example (like "Resume Game" and a script, and they all work).

I'm seriously getting slowly mad now, I hope someone here can help me figure out the problem.

ALSO those bigger, blank buttons are NOT the parent button, since it doesn't have a sprite (I've checked myself by putting a text in that empty button string and can confirm).
 

obscene

Member
Well it's hard to tell for sure. Your wall of code is a bit big and I'm ADD. Tip for the future use the [ CODE ] [ / CODE ] tags to preserve your code formatting.

If your objects have sprites, and you have a draw event, they will draw. Even if you add a draw GUI event, the normal draw event will still execute. You can either A) remove the sprite or B) add a code block to the draw even to overwrite it and then just put a comment like /// don't draw.
 
L

LordScrat

Guest
Well it's hard to tell for sure. Your wall of code is a bit big and I'm ADD. Tip for the future use the [ CODE ] [ / CODE ] tags to preserve your code formatting.

If your objects have sprites, and you have a draw event, they will draw. Even if you add a draw GUI event, the normal draw event will still execute. You can either A) remove the sprite or B) add a code block to the draw even to overwrite it and then just put a comment like /// don't draw.
First of all, thank you very much for your constructive reply. I didn't know you could format it to look like code, but i should've known in better hence this is a forum with a lot of programmers haha.

I've solved the problem by doing A. simply removing the sprite and drawing the sprite in the Draw GUI event. Also, I've changed instance_destroy(OBJECT) to with(OBJECT) instance_destroy();
AND I've changed the big ifs to switch, so its easier to add buttons later
 
Top