Book Image

Mastering Android Game Development

By : Raul Portales
Book Image

Mastering Android Game Development

By: Raul Portales

Overview of this book

Table of Contents (18 chapters)
Mastering Android Game Development
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
API Levels for Android Versions
Index

The GameFragment


Now that we have tweaked the main menu, it is time to work on the GameFragment.

There are two essential game features we have not even built yet: score and lives. We are going remedy that now. First we need to make space for them in the layout, then we have to write some code to actually take care of both features.

For the UI of the score and lives we are going to use standard Android components. We have built a lot of features into our GameEngine, but we do not want to reinvent the wheel. Since Android provides a good way to define layouts and make UIs we are familiar with, it would be a waste to not make use of it.

Note

Using the standard Android Views can save you a lot of time.

We are going to make the game area smaller by adding a column to each side. We will place the new UI elements there and we will link them to GameObjects to update them as the game progresses.

While we could overlay the controls on top of the GameView instead of having letterboxes, note that we are using...