Creating the explosion effects

We're going to build out the explosion effect that will play when an enemy dies. The effect will also play when an enemy makes contact with the player. The effect will comprise three parts:

  • The explosion line: This is a line that will expand outward when the animation starts.
  • The explosion bulb: This is a giant fireball that will swell and fade out; this is what will actually make it look like an explosion.
  • Smoke particle effect: This is a puff of smoke that will linger on after the explosion.

Creating the class

We're going to make a new class named ExplosionEffect in the source folder. The class extends the FlxGroup object.

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

package; import flixel.group.FlxGroup; class ExplosionEffect ...

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.