Flixel Power Tools FlxControl

Back to the Flixel Power Tools

This class makes it painfully easy to quickly set-up controls for your game, and then it takes control over the motion and physics of your player sprite. Acceleration, deceleration, jumping, firing, gravity, cursor keys, WASD, IJKL, heck anything you like! It can cope with a lot. 2 players on the same keyboard? No problem, it’s just 2 lines of code!

It might seem strange to make a class for keyboard controls when Flixel makes it so easy anyway, but I promise this will save a lot of repeat code and maybe even add some features you always wanted?! 🙂

Screen Shot

Code Example


// The player sprite will accelerate and decelerate smoothly
FlxControl.create(player, FlxControlHandler.MOVEMENT_ACCELERATES, FlxControlHandler.STOPPING_DECELERATES);
// Enable cursor keys, but only the left and right ones
FlxControl.player1.setCursorControl(false, false, true, true);
// Gravity will pull the player down
FlxControl.player1.setGravity(0, 400);
// All speeds are in pixels per second, the follow lets the player run left/right
FlxControl.player1.setMovementSpeed(400, 0, 100, 200, 400, 0);

Recent Flixel Power Tool Posts

  1. Flixel Power Tools v1.9 Released
  2. Flixel Power Tools v1.8 Released - Let's get clicky
  3. Flixel Power Tools v1.7 - Kaboom!
  4. Flixel Power Tools v1.6 released including FlxControl
  5. Flixel Power Tools v1.5 - A monster of an update!
  6. FlxScreenGrab and FlxScrollZone added to Flixel Power Tools
  7. Flixel Power Tools v1.3 - Now Flixel 2.5 compatible!
  8. FlxHealthBar added to Flixel Power Tools

3 Responses

Leave a comment

Make yourself heard