Keybindings?

0 favourites
  • 7 posts
  • Hey there!

    I am looking for a tutorial or a way to do keybindings. I searched for it, and couldn't find any post about this.

    Keybindings like;

    In game you go to options -> set a key for jump/attack and other buttons, save, and then be able to use those keys you set in options, in game.

    Anyone?

    Thanks in advance.

  • I think this is pretty self-explanatory.

    If you have trouble with it nonetheless, just holler at me

  • I think this is pretty self-explanatory.

    If you have trouble with it nonetheless, just holler at me

    Hey there! ^_^

    Thanks for taking your time, but no i have absolutely no idea what you did there.

    I want to be able to map keys for Jump/Attack/Dash and so on. Not last key pressed is it, etc.

    Just a normal way where you go to options, and bind the keys you want to movement.

    Save em and then use em ingame, like any options/keybind set on.. any game really.

    Thanks for trying though, i just think you got me wrong ^_^

    Thanks anyway!

  • The group "for testing" is only for getting the keycodes, it doesnt bind keys to anything, it just sets the variable "keycodeCheck"

    1. Press a button or key ingame to get the corresponding keycode of it. You can see the keycode when you watch the variable "keycodeCheck" in the Debugger.

    2. Once you know the keycodes you can create variables for all your controls (Jump/Attack/Dash) and assign default values to them (the keycodes of the keys/buttons you got in step 1.) This will be the standard Keybindings the game starts with.

    3a. (this is the easy way) All you have to do from here is building a menu where the player can either press a button/key to assign a key to an action (jump)

    3b. or he can choose from a list of available buttons/keys.

    In this case you would need a list of all keys/buttons and there corresponding keycode, maybe saved in an .xml file.

    4a. when the player pressed the button/key you can get the keycode with the expression "Keyboard.LastKeyCode" for keyboard or "Gampad.LastButton(gamepadIndex)" for gamepad. Set the variable for the action (jump) to the keycode

    4b. Like above but instead of pressing a button the player would choose a button/key from a list.

    example jump button/key.

    you want the standard jump key to be spacebar on keyboard and A on gamepad.

    Use the "for testing" group stuff to get your corresponding keycodes. (spacebar= 32 A=0 ...i think )

    create variable "keyJump" and set it to "32"

    create variable "padJump" and set it to "0"

    Give the player a way to choose the own button/key 4a or 4b

    set the variable "keyJump" or "padJump" to the new value "n"

    I hope it helps.

    I would highly suggest to pick the "a" route, where the player has to push a key to assign it. It's mutch easyer to implement and more convenient for the player.

    But maybe i still totally misunderstood what you want

  • The group "for testing" is only for getting the keycodes, it doesnt bind keys to anything, it just sets the variable "keycodeCheck"

    1. Press a button or key ingame to get the corresponding keycode of it. You can see the keycode when you watch the variable "keycodeCheck" in the Debugger.

    2. Once you know the keycodes you can create variables for all your controls (Jump/Attack/Dash) and assign default values to them (the keycodes of the keys/buttons you got in step 1.) This will be the standard Keybindings the game starts with.

    3a. (this is the easy way) All you have to do from here is building a menu where the player can either press a button/key to assign a key to an action (jump)

    3b. or he can choose from a list of available buttons/keys.

    In this case you would need a list of all keys/buttons and there corresponding keycode, maybe saved in an .xml file.

    4a. when the player pressed the button/key you can get the keycode with the expression "Keyboard.LastKeyCode" for keyboard or "Gampad.LastButton(gamepadIndex)" for gamepad. Set the variable for the action (jump) to the keycode

    4b. Like above but instead of pressing a button the player would choose a button/key from a list.

    example jump button/key.

    you want the standard jump key to be spacebar on keyboard and A on gamepad.

    Use the "for testing" group stuff to get your corresponding keycodes. (spacebar= 32 A=0 ...i think )

    create variable "keyJump" and set it to "32"

    create variable "padJump" and set it to "0"

    Give the player a way to choose the own button/key 4a or 4b

    set the variable "keyJump" or "padJump" to the new value "n"

    I hope it helps.

    I would highly suggest to pick the "a" route, where the player has to push a key to assign it. It's mutch easyer to implement and more convenient for the player.

    But maybe i still totally misunderstood what you want

    Hey.. No this doesnt really help, i still dont understand what you are trying to do/say. I know what you mean by the IDEA, but not just how to execute it. I just want a player to be able to go to options, and bind a key upon pressing on it. For example, press on ''Jump'' and then the player presses a KEY on keyboard or gamepad and done. Now jump = the key the pressed. I just dont know how to do that. Thanks for trying though, im gonna try to find someone to make a capx and pay them like 30$ or something.

    Thanks for your time anyway.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • just a thought..

    capx> http://s000.tinyupload.com/index.php?fi ... 6798188593

    Yes! That is it!! Thanks aloooooot! So perfect <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">))

    Thank you very much for putting down your time to make this capx, really! ^_^

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)