O'Reilly logo

Android Game Recipes: A Problem-Solution Approach by J. F. DiMarzio

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

Chapter     12

Moving an Enemy

Moving a character around the screen—be it a person, animal, robot, or vehicle—is one of the more crucial parts of a compelling game. Chances are, if you have tried to create a character that moves freely in a game, you have run into some issue.

This chapter will present solutions to help you add enemies to your game. Solutions in this chapter include loading enemies into predetermined locations within your game, and moving enemies along a specific path.

12.1 Load Enemies to Predetermined Locations

Problem

The game does not load enemies in the correct locations.

Solution

Use a class to determine where enemy spawn points are.

How It Works

Many game types have “spawn points” where characters will generate. To ...

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