Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

Custom keybinds/name input?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 fuerchter   Members   -  Reputation: 128

Like
0Likes
Like

Posted 08 August 2012 - 04:51 AM

Hi there
I've googled this topic for a bit but didn't come up with a good solution yet so I thought I might bring this up here:
Is there a way to write custom keybinds for an options menu (e.g. there is an entry for "Up" in the game and you can then rebind it for whatever key you like: w, t, up, enter etc...). I guess the menu has to check every single key for whether it was pressed during the rebind? (also I'd like to then save each individual bind to a config file but I'm going to read up on how to do that myself ;) ).

The same basically goes for entering a name, right? I mean, it also has to check every key and write the associated letter :S

I've seen people do that by writing out every Key, but I guess thats no graceful solution?
greetings

//EDIT:
Sorry for posting this ^^ I didn't know there was already a thread on this here -.-

Edited by fuerchter, 09 August 2012 - 03:27 AM.


Ad:

#2 Koder4Fun   Members   -  Reputation: 146

Like
0Likes
Like

Posted 14 August 2012 - 09:12 AM

The key is to define a list of actions that is needed by your game: up, down, left, right, jump, fire, etc.. and store on these actions the key selected:
Keys up, down, left, right, jump, fire;

Now when you enter your option menu to configure "jump" action (for example) you need to listen for keyboard pressed keys and, when is pressed only one key, you can store jump binding like this:
jump = Keyboard.GetState().GetPressedKeys()[0];

You need to take care to wait the release of the key used in the option menu to enter the "key selection mode" (if you use Enter you need to wait for Enter release to avoid to bind jump to enter key).

This link can help you (but I don't know your programming level):
http://joecrossdevel...yout-and-goals/

Check also this link, is usefull for GamePad/Mouse/Keyboard input design:
http://classes.soe.u...board-input.pdf
Please vote usefull replies.
Marco Sacchi
Coding is a challenge ... but solving problems is the fun part
My Blog - XNA Italian portal




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS