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 add the imports:
import flixel.FlxSprite; import flixel.group.FlxGroup; import flixel.util.loaders.TexturePackerData; import flixel.tweens.FlxTween; import flixel.tweens.FlxEase;
There are no real surprises here; we'll be using the TexturePackerData...