• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Windows Question about buttons

M

Mariusblock

Guest
I have a problem, I want to make the menu with buttons. I made a parent button and 2 "child" buttons called button_start_game and button_exit_game and they work when I press with the left mouse button the game starts or closes. but there is a problem.. the text on the buttons wont show up. I have just 2 black buttons without text when I start the game. this is the code I've used:

obj_button: Events: -Create: ///Initialize the button
button_text = "";
button_action = scr_exit_game;

-Left Pressed: ///Call the button action
script_execute(button_action);

-Draw: ///Draw the button and the text
draw_self();
draw_set_halign(fa_center);
draw_set_valign(fa_middle);
draw_text(x, y, button_text);
draw_set_halign(fa_left);
draw_set_valign(fa_top);

obj_start_button: Events: -Create: /// initailize the start button

button_text = 'Start Game';
button_action = scr_start_game;

obj_exit_button: Events: -Create: /// initailize the exit button
button_text = 'Exit';
button_action = scr_exit_game;

scr_exit_game: ///script_exit_game
game_end();

scr_start_game: ///script_start_game
room_goto(rm_tutorial);
 
M

Mariusblock

Guest
I just realized that I posted it into the wrong section how to move it?
 
A

Aura

Guest
You can use the Report button to get the topic moved to the appropriate forum by a moderator. In this case, I've already reported it, so you don't need to worry.

First of all, you don't need the Create event in the parent object as it is pretty much redundant there. It isn't even getting executed as the Create events of children objects are overwriting it. (Read this for further information). Use the parent object for the sole purpose of detecting a click and drawing the text as variable declaration is being handled by the children objects.

As for your main problem, I guess you're drawing black text on black buttons. Use draw_set_colour() before drawing the text. For further study and investigation, read up this topic.
 
Top