I figure one of the best ways to learn Flixel is to attempt some mods to the already awesome
mode. This mod will add jetpack functionality and a particle emitter to the player character.
I'm a newbie to AS3 (and to making games for the most part), so feel free to offer suggestions on how to clean up the code.
The only file you will be altering for this tutorial is Player.as
1. Open Player.as
2. In the Player class, embed the jet image that is currently being used for the enemies.
[Embed(source="../../../data/jet.png")] private var ImgJet:Class;
3. Also in the Player class, add some variables.
_boosters will keep track of whether the jetpack is on or not.
_fuel will keep track of how much juice is in the tank.
_jets will emit particles and make you look cool.
private var _boosters:Boolean;
private var _fuel:int;
private var _jets:FlxEmitter;
4. In the Player function, set the values of
_fuel and
_jets. Kill the jets so they aren't firing when the game starts.
_fuel = 500;
_jets = FlxG.state.add(new FlxEmitter(0,0,0,0,null,0.01,-10,10,20,50,0,0,0,0,ImgJet,15)) as FlxEmitter;
_jets.kill();
The code for the rest of the steps should be placed in the update function.
5. If you are holding down the jump button and are at the height of your jump, turn on boosters and start the jets. Starting the jets will make particles start shooting out.
if(FlxG.kA && (velocity.y >= -40 && velocity.y <= 20))
{
_boosters = true;
_jets.reset()
}
6. If the boosters are on and you let go of the jump button, turn the boosters off and kill the jets.
if(_boosters && !FlxG.kA)
{
_boosters = false;
_jets.kill();
}
7. If the boosters are on and you have fuel, make the player go up, drain fuel, and center the jets on the x and y position of player.
if(_boosters && _fuel>0)
{
velocity.y = -70;
_fuel += -10;
_jets.y = this.y;
_jets.x = this.x + 3;
}
8. If the boosters are off and fuel isn't maxed out, increase the fuel.
if(!_boosters && _fuel<400)
{
_fuel += 20;
}
9. Save, compile, and play.

That's it! 9 easy steps.
I think I might work on this a bit more and add a fuel gauge to the HUD.