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

Adding some fire tiles


These new GameObject derived objects will mean instant death to Bob. They won't move, but they will be animated. We will see we can achieve this just by setting the already existing properties of GameObject.

Adding this feature into our game is simple because we have already implemented all the features we need. We already have a way to locate and add new tiles, a way to detect and respond to a collision, sprite sheet animation, and so on. Let's do it step-by-step, then we can add these dangerous and life-threatening elements into our world.

We can put the entire functionality of the class into its constructor. All we do is configure the object much like we did our Grass object, but in addition, we configure it with all the animation settings, like we did to the Player and Guard objects. The fire.png sprite sheet has three frames of animation that we want to play over the course of one second.

Create a new class, call it Fire, and add the following code to it:

import android...