1
\$\begingroup\$

What is the best method for creating user definable or user changeable keys in a flash game?

Edit: I meant, user changeable keys. Not user changeable flash buttons. Why would a user need to change the graphic of a button in a game?

\$\endgroup\$
5
  • \$\begingroup\$ What should be changeable? The look, the position, the label? Please add some information to your question about what you're trying to do. \$\endgroup\$
    – bummzack
    Aug 27 '10 at 6:38
  • 2
    \$\begingroup\$ I'm stuck between you meaning buttons as GUI elements and keyboard 'buttons'. \$\endgroup\$ Aug 27 '10 at 8:02
  • \$\begingroup\$ @The Communist Duck: Good point. I didn't even think about that. I guess we both agree that some clarification is needed here. \$\endgroup\$
    – bummzack
    Aug 27 '10 at 8:03
  • \$\begingroup\$ I think it's pretty safe to assume keyboard keys \$\endgroup\$ Aug 27 '10 at 9:28
  • \$\begingroup\$ Just to make sure, when you say "user-definable" you mean definable by the person playing your Flash game (i.e. the player), and not definable by you (i.e. the developer, i.e. the Flash user), right? \$\endgroup\$ Aug 27 '10 at 11:29
3
\$\begingroup\$

I'll answer the second question, "Why would a user need to change the graphic of a button in a game?" I think it would be an awesome idea to have a game like Upgrade Complete that is focused around the user customizing and upgrading the UI. Maybe the game has a set of undifferentiated buttons, and the player has to label and customize them so that she can figure out and remember what they do?

As for custom keys? Capture their keycodes and store them, then test against those keycodes in the input logic. You'll have some sort of options screen where you can set the custom keycodes, then use the settings in the game proper instead of using constants or magic numbers for your action buttons.

The trickiest part, oddly, is displaying the custom keys' names to the user. As far as I can recall, Flash doesn't have a lookup table matching keycodes with key labels. I'm guessing you'd need to create a dictionary yourself with the most important keys, and then just refer to any special cases as something like KEY_1876.

\$\endgroup\$
1
\$\begingroup\$

Use the library I created, Gamepad.

\$\endgroup\$
0
\$\begingroup\$

You could create a class that extends Sprite or MovieClip that it's inputs are the height, width, x, y and action (function), and create a new instance of that class each time a user wants to create a new button.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .