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

Get Haxe Game Development Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.