Book Image

Learning Java by Building Android Games

By : John Horton
Book Image

Learning Java by Building Android Games

By: John Horton

Overview of this book

Table of Contents (17 chapters)
Learning Java by Building Android Games
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Drawing with Android Canvas


So far, we have been using the Android UI designer to implement all our graphics. This is fine when all we need are objects such as buttons and text.

It is true that there is more to the Android UI elements than we have explored so far. For example, we know we can do a lot more with the Animation class, and we very briefly saw that we can assign any image we like to represent one of the UI elements.

As an example, we could assign game characters such as spaceships to UI elements and animate them.

However, if we want smoothly moving spaceships with accurate collision detection, cute characters, and gruesome baddies with multiframe, cartoon-like animation, then we are going to need to move away from predefined UI elements.

We are going to need to start looking at and designing with individual pixels, lines, bitmaps, and sprite sheets. Fortunately, as you might have guessed, Android has some classes to make this nice and easy for us. We will be learning how to get started...