Building a HUD class to display control buttons and text

The HUD, as usual, will display all the on-screen information to the player. The HUD for this game (as we saw at the start of the chapter) is a bit more advanced and as well as regular features like the score and player's lives it also has the control buttons.

The control buttons are basically slightly transparent rectangles drawn on the screen. It will be important that when we detect the player's touches we determine accurately if a touch happened within one of these rectangles as well as which rectangle.

An entire class dedicated to these rectangles (as well as the usual text) seems like a good idea.

Furthermore, as we did with the Snake and the Apple classes in the previous project, the ...

Get Learning Java by Building Android Games - Second Edition 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.