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

Animation, sprite sheets, and the Snake home screen


In the previous chapter, we used a bitmap to draw text, a circle, a line, and a single pixel on the blank bitmap we created in Java code. We then displayed the bitmap with all of its doodling using the Canvas class. Now we will look at a technique to draw two dimensional images, sometimes referred to as sprites. These are made from predrawn images. The images can be as simple as a plain pong ball or as complex as a glorious two-dimensional character with muscle definition, elaborate clothing, weapons, and hair.

So far, we have animated with unchanging objects, that is, we have moved a static unchanging image around the screen. In this section, we will see how to not only display a predrawn bitmap image on the screen but also continually alter it to create the illusion of on-the-spot animation.

Of course, the ultimate combination would be to animate the bitmap both by changing its image and moving it around at the same time. We will see that...