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

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.