HaxeFlixel InputHelper

Posted by
August 20th, 2014 3:51 pm

Have you ever received a comment like “I would like to play this, but I use an AZERTY keyboard layout and the controls are impossible” or “I wish that key X did this instead of Y”?  Ever spent time hard coding user inputs into a game only for it to be a pain to change it around?  Ever wasted precious time writing a way for users to change their own keys in game?  Oh, and happen to use HaxeFlixel?

If you answered yes to any of these questions, then you need InputHelper, the new simple way to map keyboard keys to game functions without the hassle, available now for HaxeFlixel for the low, low price of… nothing!

InputHelper is a small helper application for HaxeFlixel games.  It abstracts the interface between the user and the game through a series of virtual buttons that can be mapped to different functions.  Instead of checking against the keyboard, mouse, or gamepad and updating your game objects, InputHelper has you check against buttons named up, down, left, or right plus any additional buttons you define.

Next, add any virtual buttons you want with InputHelper.addButton(buttonName).  Does your game need a jump button?  InputHelper.addButton(“jump”).  Attack button?  InputHelper.addButton(“attack”).    Throw flaming gopher button?  InputHelper.addButton(“FlamingGopher”).  Now those gophers are ready to fly!!

Keyboard keys can be assigned to your virtual buttons simply by calling InputHelper.assignKeyToButton(Key, buttonName).  Want multiple keys assigned to the same virtual button?  No problem!!  By typing InputHelper.assignKeyToButton(“W”, “up”); and InputHelper.assignKeyToButton(“Z”, “up”); both QWERTY and AZERTY keyboard users can both press up in the way they want.  Your game objects will be checking against the virtual button and won’t know the difference!!
Every game loop, call InputHelper.updateKeys().  Once that is done, use InputHelper.isButtonPressed(buttonName) or one of the other functions in place of the FlxG.keys functions.  Done!
But that’s not all.  Download InputHelper in the next (Editor note: Insert days to next Ludum Dare here) days and receive InputHelperMenuState absolutely free!!!
Just switch to the InputHelperMenuState in your HaxeFlixel game and give your users the ability to change their keymappings instantly with no work on your part.  InputHelperMenuState integrates seamlessly with InputHelper to allow users to click and reassign keys.  The screen is simple (and kind of ugly) but its free and you should stop complaining!
Get InputHelper here.
Get InputHelperMenuState here.
Get Readme here.
Want to try before you buy?  Download a quick .swf file demo here.

One Response to “HaxeFlixel InputHelper”

  1. Sruloart says:

    This is cool. Very cool. ‘This should be in HaxeFlixel’s addons’ kinda cool. PULL REQUEST AT ONCE! :)
    BTW, MIT license?

Leave a Reply

You must be logged in to post a comment.

[cache: storing page]