Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Haxe Game Development Essentials

You're reading from   Haxe Game Development Essentials Create games on multiple platforms from a single codebase using Haxe and the HaxeFlixel engine

Arrow left icon
Product type Paperback
Published in Nov 2015
Publisher
ISBN-13 9781785289781
Length 188 pages
Edition 1st Edition
Concepts
Arrow right icon
Toc

Table of Contents (10) Chapters Close

Preface 1. Getting Started FREE CHAPTER 2. Building a New Game 3. Dealing with Menus and Screen Flow 4. Delving into Animations and Gameplay 5. Adding Sound 6. Working with Configuration Files 7. Deploying to Multiple Platforms 8. What's Next? Index

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

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image