O'Reilly logo

Beginning Android Tablet Games Programming by Jeremy Kerfs

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Enhancing the Game Sprites

In this game, you demand a lot from your sprites. To handle the new functionality, you need a couple of new methods and variables that all the sprites use. Although only one sprite may actually take advantage of a particular feature, rather than create additional classes, you have every game sprite inherit from SpriteObject because the sprites are largely the same—there is no need to clutter the project.

However, if you expand the game, and you want the boats to be able to fire back, change direction, or spawn smaller boats, then you might want to create a special boat class that embodies these capabilities. Any time a sprite or object uses two or more unique functions, I usually make a new class for it.

Follow these ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required