Applying a HUD to the camera
A HUD (Heads-Up Display
) can be a very useful component for even the simplest of games. The purpose of the HUD is to contain a set of buttons, text, or any other Entity
object in order to supply the user with an interface. The HUD has two key points; the first being that the HUD's children will always be visible onscreen, regardless of whether or not the camera changes position. The second point is the fact that the HUD's children will always be shown in front of the scene's children. In this chapter, we're going to be applying a HUD to the camera in order to supply users with an interface during gameplay.
How to do it...
Import the following code into the onCreateEngineOptions()
method of any BaseGameActivity
of your choice, substituting the camera type in this code snippet if necessary:
@Override public EngineOptions onCreateEngineOptions() { // Create the camera Camera mCamera = new Camera(0, 0, WIDTH, HEIGHT); // Create the HUD HUD mHud = new HUD...