O'Reilly logo

Haxe Game Development Essentials by Jeremy McCurdy

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding the new game HUD

Finally, we need to add the new HUD to the game. We're also going to use a FlxGroup object to prevent our enemies appearing over the game's UI. Open up PlayState.hx to get started.

Adding imports

As usual, we have a few imports to add:

import ui.GameHUD;
import flixel.group.FlxGroup;

Adding variables

We need to add a couple of new variables:

private var gameHud:GameHUD;
private var enemyLayer:FlxGroup;

The gameHud variable will store our GameHUD class, and enemyLayer will store the group that will be used to layer enemies under the HUD.

Housekeeping

Like when we made updates to the LevelEndScreen class, we need to change a few things before we start adding new content. To start, go into the variables section and delete these two ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required