User Tag List

Results 1 to 9 of 9

Thread: player control - assign custom keys

  1. #1
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleSWF Export Module

    Join Date
    Sep 2006
    Posts
    311
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    player control - assign custom keys

    Hello,
    i want to let the user assign custom keys to his controller (keyboard or joystick), save this configuration and load it at game start.

    Problems:
    The "set key" action from the player object allows only direct input, no variables.
    The controlX object has only 2 fire buttons.
    The joystick object has no actions to set the player buttons.

    So i have to workaround it:
    Get the pressed keys/buttons with ctrlX/joystick object,
    put them in a array and compare them during gameplay in a key pressed condition.
    But i could never use the "read joystick state" conditions from the player object.

    Question:
    Is there any way to assign the keys/buttons by variables in a action?

    Thanks,
    Quinto

  2. #2
    Clickteam Clickteam
    Olivier's Avatar
    Join Date
    Jun 2006
    Posts
    3,000
    Mentioned
    9 Post(s)
    Tagged
    1 Thread(s)

    Re: player control - assign custom keys

    I've bypassed the problem but it was quite a hassle, and the word is weak.

    Basically I'm using a unique number for each keyboard/joypad/mouse key or button. I let the player configure the contols as he wishes and store his choices in an Array. This gives me something like 32, 33, 34. And I know that the first number is for going left, the second for going right and the third for firing.

    Then prior to launching the game levels, I assign each control again (pseudo-code):
    If 1st number = 32
    Set input key 2 to "Left Arrow"
    etc..

    It's a bit complicated but works like a charm with any device (even combined), and without the need of an extension. Hope it helps.

  3. #3
    Forum Moderator Fusion 2.5 DeveloperHTML5 Export ModuleiOS Export ModuleSWF Export Module
    DavidN's Avatar
    Join Date
    Jun 2006
    Location
    Boston, MA, USA
    Posts
    4,044
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: player control - assign custom keys

    That works, but it's a pain to set up all the events for every possible combination.

    I use a combination of that method and the ControlX object - store the values that you want to recognize for each key in the Global Values or Strings (and save/load them to a file when you need to). For example, in my latest project I've named a few values BtnUp, BtnDown, BtnJump, and so on.

    Then you just have to replace your "User presses..." events with things like "ControlX: Key by value (BtnJump) is pressed".

  4. #4
    Clickteam Clickteam
    Olivier's Avatar
    Join Date
    Jun 2006
    Posts
    3,000
    Mentioned
    9 Post(s)
    Tagged
    1 Thread(s)

    Re: player control - assign custom keys

    Yes it's a real pain to setup the events, but with a wise use of Groups I was able to significantly reduce the code. In fact I assign control devices/keys to Players, so that in the actual game code I only use "Player 1: Pressed fire 1" type of events.
    But I'll definitely take a look at the ControlX object.

  5. #5
    No Products Registered

    Join Date
    Jul 2006
    Posts
    225
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: player control - assign custom keys

    Quote Originally Posted by OliverPearl
    Yes it's a real pain to setup the events,
    Quote Originally Posted by DavidN
    it's a pain to set up all the events for every possible combination.
    Quote Originally Posted by OliverPearl
    it was quite a hassle
    hmmm... looks like we have here a painful situation lol.
    Btw how would you use the ControlX object to solve this problem? You have the full code?

  6. #6
    Clickteam Clickteam
    Olivier's Avatar
    Join Date
    Jun 2006
    Posts
    3,000
    Mentioned
    9 Post(s)
    Tagged
    1 Thread(s)

    Re: player control - assign custom keys

    I have quickly checked the extension. This is how I would do it, but DavidN already said it all.

    At the setup screen store the player's custom keys in Global Values by using LastKeyPressed( "Control X" ).
    Then in the game simply use "ControlX: Key number Global Value A is pressed".

  7. #7
    No Products Registered

    Join Date
    Jul 2006
    Posts
    225
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: player control - assign custom keys

    oh ok thanks

  8. #8
    Clicker Fusion 2.5 DeveloperiOS Export Module
    FinalSpecimen's Avatar
    Join Date
    Oct 2011
    Location
    Boston, MA
    Posts
    123
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey guys, this is a really old thread so apologies for the bump, but I am desperate to find a solution to this problem. As far as I can tell, I am correctly following the instructions in the above thread for mapping Global Strings to key values. I am then recalling them using the ControlX object at runtime, using an active to store a boolean input value for the player actions ("punch" in this example) and triggering it on/off when the corresponding key is pressed/not pressed. However, when I test, I get no response. The picture below illustrates everything I've done. I have tried the ControlX conditions "key pressed" and "key (value) pressed," both yielding the same results. Please, could someone tell me what I'm doing wrong; I have been held back by this seemingly simple problem for weeks.

    problem.jpg

  9. #9
    Clicker Fusion 2.5
    Del_Duio's Avatar
    Join Date
    Sep 2008
    Location
    Cygnus X-I
    Posts
    919
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Olivier View Post
    I've bypassed the problem but it was quite a hassle, and the word is weak.

    Basically I'm using a unique number for each keyboard/joypad/mouse key or button. I let the player configure the contols as he wishes and store his choices in an Array. This gives me something like 32, 33, 34. And I know that the first number is for going left, the second for going right and the third for firing.

    Then prior to launching the game levels, I assign each control again (pseudo-code):
    If 1st number = 32
    Set input key 2 to "Left Arrow"
    etc..

    It's a bit complicated but works like a charm with any device (even combined), and without the need of an extension. Hope it helps.
    Actually, that's quite an ingenious use of ASC / CHR$ codes!

Similar Threads

  1. Control X and rebindable keys
    By J3sseM in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 11th March 2015, 02:17 AM
  2. Assign Gamepad to Player 1
    By Sloxone in forum XNA Export Module Version 2.0
    Replies: 2
    Last Post: 30th July 2012, 01:04 PM
  3. Loading player keys
    By Corlagon in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 30th September 2006, 08:00 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •