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 we have our empty class set up, let's add the imports that we'll need:
import flixel.FlxG; import flixel.FlxSprite; import flixel.text.FlxText; import flixel.util.FlxColor;
Adding variables
Next...