User Tag List

Results 1 to 6 of 6

Thread: Best way to reassign keyboard keys to initiate actions during runtime.

  1. #1
    Clicker Multimedia Fusion 2 DeveloperSWF Export Module

    Join Date
    Jan 2012
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Best way to reassign keyboard keys to initiate actions during runtime.

    Ok, I'm convinced there is always a better way, and especially with the way I do things. Ok, the task here is to have the keyboard commands change based upon which animation frame is randomly generated by an object.

    Platform game.

    So, I have a square with 12 different animations. Each one is obvious like Apple, Orange, Tree, etc. The user (young student) must know the first letter of the picture to use the keyboard key that corresponds to that letter to initiate an action for the character. So, the character collides with a magic square and the active object becomes visible with the randomly generated frame showing. The user then acquires the new ability, let's say Super Jump (the ability to jump during a jump) only when they hit the keyboard key that corresponds to the first letter of that graphic. SO, if it were the Apple graphic that randomly came up the key for Super Jump would be A, the first letter of the word Apple. Ok, I have this working great, different randomly generated graphics are then mapped to different keys for the attacks. The user has a control panel and an icon of the random animation shows on the ctrl panel with the name of the attack, so the user sees an apple on his control panel and the word Super Jump above it, then they know to press A for super jump. If an Orange had come up they would press O for super jump, etc. SO, it forces them to know the first letter of pictures to play the game essentially and the pictures change often. A sneaky way to teach kids to begin to read... anyhow, here is what I'm doing to make this happen, and I'm SURE there is a better, easier way and considering I've only programmed two of these randomly generated abilities which change the attack keys, a better way would be great before I program 26 of them :-)

    Ok,

    If you collide with the special marker a number between 0 and one less than the number of animation frames is randomly generated and the active object with X number of animations frames becomes visible with the generated frame number showing.

    This sets a global SuperJump equal to the generated frame number and activates a group called Super Jump.

    This is where I think a more elegant (instead of my hacked up) solution can present itself I'm sure.

    The now active group has a check for each possible value of SuperJump
    If SuperJump = 0 then activate the A group
    If SuperJump = 1 then activate the B group
    etc.

    So, I then activate the group that corresponds to the letter A
    It starts with 'Repeat while 'A' is pressed and then proceeds to do all the stuff I need the character to do to 'Super Jump'

    I have a B, C, D, E, F, etc group that I activate if SuperJump = 2, 3, 4,5,6, etc. Each with the proper 'Repeat while 'B' is pressed, Repeat while 'C' is pressed, etc... each group has the proper keyboard key that corresponds to the animation frame value activated so that the user can now use the first letter of the graphic to make the Super Jump work.

    So all this works but it is a huge number of tests to activate one of many many subgroups. If I could 'Repeat while (parse in my string) is pressed' I could cut out all those subgroups, for one... and there is probably a better way to assign the activation of the subgroups than by using a separate event for each possible value of SuperJump.

    Is there a better way do this? I want the keyboard key that sets off my action to be reassigned based upon the animation frame number of a graphic that has that number randomly generated :-) I got it working and it is really cool, but clunky :-)

    Thanks for help!

  2. #2
    Clickteam Clickteam
    LB's Avatar
    Join Date
    Jun 2007
    Location
    Richardson, Texas, North America
    Posts
    8,937
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Have you tried the Control X object?
    Working as fast as I can on Fusion 3

  3. #3
    Clicker Multimedia Fusion 2

    Join Date
    Sep 2006
    Location
    Britain, South Coast
    Posts
    1,030
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    And if for some reason you can't use Control X, a method we used to use in the old days is to hide an Edit Object offscreen and always give it focus, then every frame check the text it contains and erase it when you've processed it.

    E.g.
    Text is blank.
    Player presses Y for Yellow
    Text now says "Y"
    Check what text says and respond to it
    Empty the edit object

    You may also want to loop through each letter in the edit object, in case they somehow pressed multiple keys since your last frame (or always check the last key).

    Just in case you want to use only standard objects.

  4. #4
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export ModuleUnicode Add-on
    Fanotherpg's Avatar
    Join Date
    Jul 2006
    Location
    High Wycombe, Buckinghamshire, UK
    Posts
    3,663
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Key Object is the best one IMHO.

  5. #5
    Clickteam Clickteam
    LB's Avatar
    Join Date
    Jun 2007
    Location
    Richardson, Texas, North America
    Posts
    8,937
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Key object does not let you reassign keys in the way Control X does, Fano.
    Working as fast as I can on Fusion 3

  6. #6
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export ModuleUnicode Add-on
    Fanotherpg's Avatar
    Join Date
    Jul 2006
    Location
    High Wycombe, Buckinghamshire, UK
    Posts
    3,663
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can work it out. Each of the keys got it's ID. So just in Menu set for pressing Up - check which key was pressed with Key Object and Set it's ID in global variable, and then refer to that variable. Trust me it works.

    Example provided.
    Attached files Attached files

Similar Threads

  1. Keyboard Object won't read keys held down after frame transition
    By Strife in forum Multimedia Fusion 2 - Technical Support
    Replies: 0
    Last Post: 15th September 2013, 04:33 PM
  2. Restricted actions on joysticks and keyboard input
    By Netflyer165 in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 1st April 2012, 03:22 AM
  3. accelerator keys aka hot keys don't work
    By Gitaarheld in forum Install Creator and Patch Maker
    Replies: 1
    Last Post: 23rd February 2009, 10:05 AM
  4. Retrive Keyboard and Gamepad keys
    By Simon_Belmont in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 19th September 2008, 09:52 PM
  5. How to combinate two keys to perform actions?
    By The Thinker in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 8th November 2006, 12:19 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
  •