Flixel Power Tools FlxControl
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?! 🙂
// 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
- Flixel Power Tools v1.9 Released
- Flixel Power Tools v1.8 Released - Let's get clicky
- Flixel Power Tools v1.7 - Kaboom!
- Flixel Power Tools v1.6 released including FlxControl
- Flixel Power Tools v1.5 - A monster of an update!
- FlxScreenGrab and FlxScrollZone added to Flixel Power Tools
- Flixel Power Tools v1.3 - Now Flixel 2.5 compatible!
- FlxHealthBar added to Flixel Power Tools
3 ResponsesLeave a comment
Make yourself heard
All about Photon Storm and our
HTML5 game development services
Filter our Content
- Cool Links
- Flash Game Dev Tips
- Game Development
- Geek Shopping
- In the Media
- Phaser 3