Making enemies
Next, we'll start making our enemies, and then we'll add them to the screen. To do this, we'll make a new class that will handle displaying our enemies. They will appear at random places on the screen after random time intervals.
Creating the enemy class
If you're using FlashDevelop, you can create a class by right-clicking on the source folder and going to Add | New Class. Then, name it Enemy
and set its base class to FlxSprite
.
If you're using Sublime Text, you can make a new class by going to File | New File and saving the file under the source folder as Enemy.hx
.
FlashDevelop will create part of the class for you. In Sublime Text, you'll have to add most of the class by hand. For FlashDevelop, remove source
from the package
section. We're not going to use packages for classes that sit directly under the source folder.
Your class should look like this:
package; import flixel.util.FlxTimer; import flixel.FlxSprite; import AssetPaths; class Enemy extends FlxSprite { public...