Updating enemies

We're going to add some new art and functionality to our enemies. We'll add a two-frame looping animation that will make the enemies seem livelier.

The enemies will be made to spawn offscreen on the right and at a random y coordinate. They will fly across to the left side of the screen. After flying to the left side of the screen they will respawn on the right side of the screen at a new y coordinate and begin again.

They will also have a function that can be called when they are destroyed by the player. This will fade them out and then make them respawn.

To start, open Enemy.hx so we can make the changes we need.

Adding imports

To start, let's add the new imports we'll need:

import flixel.FlxG; import flixel.tweens.FlxTween; import ...

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.