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. ...

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.