Adding new key mappings to FlxG.keys

Dysiode

  • Posts: 10
Howdy, I'm wondering if it's possible to add new key mappings to FlxG.keys. The addKey() method is protected and trying to replace the instance with a custom class that exposes it gets results in no apparent change.

If it's not possible to add new keys it should would be nice if Home, End, Page Up, and Page Down were added to the list of keys. Doing so would make the numpad (I know, poor design decision, hush.) at least usable if Numlock is off. As it stands Shift + Numpad 7 = Home but Home isn't registered so Flixel gets all kinds of pissy.

Jon

  • *
  • Posts: 17528
We could switch addKey() to public, if that works for you as a solution.

If you update engine.swc as directly here, you'll find that function now unlocked.
http://community.stencyl.com/index.php/topic,1131.0.html

« Last Edit: June 20, 2011, 01:10:14 am by Jon »

Dysiode

  • Posts: 10
Well, it doesn't complain about the protected methodness anymore, but it does throw this:
Code: [Select]
ReferenceError: Error #1056: Cannot create property HOME on org.flixel.data.FlxKeyboard.
at org.flixel.data::FlxKeyboard/handleKeyDown()[/Users/jon/Desktop/stencyl/plaf/flash/flixel/org/flixel/data/FlxKeyboard.as:245]
Which yielded no results through my brief search through their 2.35 branch on Github so sadly I can't be of any help :<

But, maybe that's the reason it was protected in the first place XD

With that said, that'll work perfectly as a solution =D ~not above a little custom work to make things happen~

Jon

  • *
  • Posts: 17528
My guess is that you have to add an explicit member variable to FlxKeyboard for each key you want to add. You can't just call addKey.

If you could get me a list of said keys you want to add, in addition to their virtual key codes (which are all in FlxKeyboard.as at the top), we could add those keys in.