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
About the Author
About the Reviewers
Platformer – Guns, Life, Money, and the Enemy

Preparing OpenGL ES 2

First we start off with our Activity class, which as before is the entry point into our game. Create a new project and in the Application Name field enter C9 Asteroids. Choose Phones and tablets, then Blank Activity when prompted. In the Activity Name field type AsteroidsActivity.


Obviously you don't have to follow my exact naming choices but just remember to make the minor alterations in code to reflect your own naming choices.

You can delete activity_asteroids.xml from the layout folder. You can also delete all the code within the file. Just leave the package declaration.

Locking the layout to landscape

Just as we did for the previous two projects, we will make sure the game runs in landscape mode only. We will make our AndroidManifest.xml file, force our AsteroidsActivity class to run with a full screen, and lock it to a landscape orientation. Let's make these changes:

  1. Open the manifests folder now and double-click the AndroidManifest.xml file...