Flixel Power Tools FlxWeapon

Back to the Flixel Power Tools

FlxWeapon is a comprehensive weapon manager for any game that involves shooting! It handles the creation, pooling and re-use of bullets. It supports:

  • Angled Bullets
  • Bullet Velocity and Acceleration
  • Sounds
  • Callbacks
  • Fire at the Mouse
  • Fire from the Mouse
  • Fire from a parent Sprite
  • Fire at a target Sprite
  • Fire from a fixed position
  • Fire to a fixed position
  • Set the firing rate (in real-time)
  • Bullet Gravity (!)

Use it FlxControl for a really powerful combo. Weapons can be stacked onto a single player, so there’s no reason they couldn’t be firing several of them at the same time.

Screen Shot

Code Example


//	Our players space ship
player = new FlxSprite(160, 200, AssetsRegistry.invaderPNG);
 			
//	Creates our weapon. We'll call it "lazer" and link it to the x/y coordinates of the player sprite
lazer = new FlxWeapon("lazer", player, "x", "y");
 			
//	Tell the weapon to create 50 bullets using the bulletPNG image.
//	The 5 value is the x offset, which makes the bullet fire from the tip of the players ship.
lazer.makeImageBullet(50, AssetsRegistry.bulletPNG, 5);
 			
//	Sets the direction and speed the bullets will be fired in
lazer.setBulletDirection(FlxWeapon.BULLET_UP, 200);

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

9 Responses

Leave a comment

Make yourself heard