O'Reilly logo

Haxe Game Development Essentials by Jeremy McCurdy

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Making muzzle flashes

Now we're going to create the muzzle flash that will play when the player fires a projectile. This effect will comprise two parts:

  • Flash: The sparks that appear immediately when the projectile is fired.
  • Rings: A set of red rings that radiate outward, after the flash. This will make the projectiles appear more powerful.

The muzzle flash will work like a simplified version of the explosion effect, so it'll be very easy to put together.

Creating the class

To start, make a new class named MuzzleFlash in the source folder. The class extends FlxGroup.

Here's what it should look like to start with:

package;

import flixel.group.FlxGroup;

class MuzzleFlash extends FlxGroup
{
  public function new() 
  {
    super();
  }
}

Adding imports

Next, let's

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required