[Solved]How do I let user choose their own keys?

0 favourites
  • 5 posts
From the Asset Store
Who wants to be a Millionaire Clone. An educational coding source
  • Hellow~

    I'm wondering how we can let user custom their keys. Somewhere i read about using arrays, but i don't know how to start that thing. :1

    I would like to have this implemented, a desktop game, that don't let you set your own keys its pretty akward :/

    I was looking through forum pages, but i didn't see any topic related, but if it already exist, please pardon me.

    It would be nice, if you could redirect me there. (:

    Well.. that's it, have a nice day guys.

    PD. Sorry for any grammar issues.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • you dont actually need an array object. U can do, would be better but u may not.

    if your game has 7 keys forexample u can make this with 7 global variables too.

    You will going to have preset of keycodes on this global variables already. Then you will going to use "keyboard" objects "on any key pressed" event. add 7 sub "if" events to that event by using "Compare two values" event. On each, u will going to compare one of your global variable with "Keyboard.LastKeyCode". if equal, then u will going to do actions for that key.

    However this will going to be a long term control method if your game has like 30 keys. I suggest you to make your players to be able to choose "premade" key combinations. like using "awsd" instead of arrow keys ect. in such stuations.

  • Oh, i see.

    So, if the player choose... let's say A, for 'Prev Weapon', the global variable for 'Prev Weapon' should be already with one keycode on it, if it was A... it should keep working the way it was with the A. But if the user choose something like S... with the "Keyboard.LastKeyCode" it should change the A, for the S... making things happen with it. (?) or isn't? ?

    Well, thanks you Aleq , i feel like i can start messing around on Construct now. I think it would be better to discuss this with some capx, so i'll get to it.

    Please, have a nice day (:

    PD. Sorry for any grammar issues.

  • Aleq , check this

    dropbox.com/s/xhx98n8k9shsy8z/customKeyboard_test.capx

    Thank you so much!

    I make it work, the way you said it!

    But i found out that the "StringFromKeyCode" doesn't make all the string forms of the keycodes. I guess the best bet will be to make and array with the missing keys, put their names and call 'em from the array, isn't ?

    Anyways. Thanks you again!

    PD: Sorry for any grammar issues

  • im glad to help

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