GameMaker How to make a settings menu?

I

IcyZ1ne

Guest
So what I am trying to achieve is a settings menu in which the player can see which button does what, and also if he double clicks on it, he would be able to change the button to whatever he desires. This is what I've tried, but didn't seem to work.
if (image_index = 0 and keyboard_check_pressed(ord("Q")))
{
image_index = 5;
jump = keyboard_check(ord("Q"));
}
(This is just an example. I have made frames for a few buttons and tried to put this code in a left released event.)
 

Simon Gust

Member
The problem is that "jump" doesn't inherit the keyboard_checks() function.
What you can do is this:
Code:
key_for_jumping = keyboard_key;
keyboard_key is equal to the key you are pressing at that moment.
So when you press Q, jump_key will be set to Q.

Now, you don't have to check for every key on your keyboard, you can just press one and that's it.

Then in your player you can shortcut the keypress function.
Code:
jump_key = keyboard_check(key_for_jumping);
 

Simon Gust

Member
Ok , so what I understood is that in the settings room, i should have some objects which display the currently assigned button ,and the code would be like:
Create Event:
jump = key_for_jumping;
Left Released Event:
if (keyboard_check_pressed(keyboard_key))
jump_key = keyboard_check(keyboard_key);

But the problem is, how do I display the currently set key?
I doubt that the left released event would work as that is only 1 frame long.

create event
Code:
jump_key = 0;
key_for_jumping = vk_space; // default
selected = false; // when left clicked, key can be changed
step event
Code:
if (selected)
{
  if (keyboard_check_pressed(vk_anykey))
  {
     selected = false;
     key_for_jumping = keyboard_key;
  }
}
left released event
Code:
selected = true;
You can draw the key as text.
A function named chr() turns unicode into a string.

draw GUI event
Code:
var key = chr(key_for_jumping);
draw_text(10, 10, key);
I don't know if this works for keys other than character keys.
 
I

IcyZ1ne

Guest
I doubt that the left released event would work as that is only 1 frame long.

create event
Code:
jump_key = 0;
key_for_jumping = vk_space; // default
selected = false; // when left clicked, key can be changed
step event
Code:
if (selected)
{
  if (keyboard_check_pressed(vk_anykey))
  {
     selected = false;
     key_for_jumping = keyboard_key;
  }
}
left released event
Code:
selected = true;
You can draw the key as text.
A function named chr() turns unicode into a string.

draw GUI event
Code:
var key = chr(key_for_jumping);
draw_text(10, 10, key);
I don't know if this works for keys other than character keys.
Thank you so much, it now fully functions, thank you very much!
 
Top