Book Image

Android Game Programming by Example

By : John Horton
Book Image

Android Game Programming by Example

By: John Horton

Overview of this book

Table of Contents (18 chapters)
Android Game Programming by Example
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
7
Platformer – Guns, Life, Money, and the Enemy
Index

Scores and the HUD


The HUD objects will never be rotated. In addition, they are defined in the InputController class based on screen coordinates, not the game world or even Open GL coordinates. Therefore, our GameObject class is not a suitable parent class.

For the sake of simplicity, each of the three HUD classes will have their own draw method. We will see how we draw them at a consistent size and screen position using a new viewport matrix.

Once we have created all three of our HUD classes, we will add all of the object declarations, initializations, and drawing code.

Adding control buttons

The first HUD object we will make a class for, is a simple button.

Note

I am showing all the imports explicitly, as they do not get imported automatically. Note that the next two classes will need these as well. The code is all in the download bundle as usual, if you wish to just copy and paste it.

Create a new class and call it GameButton, then add the following import statements. Be sure to state the correct...