O'Reilly logo

Developing Mobile Games with Moai SDK by Francisco Tufro

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

Chapter 10. Creating a HUD

The Heads-Up Display (HUD) is a key technique that game designers use in order to provide information to the user. It's basically a set of graphics or text that are detached from the world itself and that are used to tell the player things such as how much life or mana they have left, or what their score is.

We're going to create a simple HUD that will give us really useful information such as the direction in which the character is going and its position in world coordinates. This will be enough to illustrate how to create a HUD. You will want to display more useful information in your own game. So let's go!

The basics

Create a file called hud.lua, require it from game.lua, and let's start our module.

Our HUD implementation ...

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