Creating the new game HUD

Now we're going to implement the new game HUD. This will display a series of hearts that indicate player health and show the player's score. Since we haven't fleshed out the rest of the gameplay, the health display won't do anything yet, but it will be ready for when we take care of that in the next chapter.

Creating the GameHUD class

To start, we're going to create a new class in the source/ui folder as we did with LevelEndScreen. So, make a class named GameHUD. This class will extend the FlxGroup class this time around.

For Sublime Text users, here's what the class should look like to start:

package ui;

import flixel.group.FlxGroup;

class GameHUD extends FlxGroup
{
  public function new() 
  {
    super();
  }
}

Adding imports

Now that ...

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.