Book Image

Cocos2d Game Development Blueprints

By : Jorge Jordán
Book Image

Cocos2d Game Development Blueprints

By: Jorge Jordán

Overview of this book

Table of Contents (15 chapters)
Cocos2d Game Development Blueprints
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Chapter 8. Defend the Tower

War has existed almost since the dawn of humanity, and because of that most civilizations have raised castles and fortresses to defend themselves from their enemies.

Of course, we don't like wars but what about playing at war? Or simulating that we are being besieged? In this chapter, we are going to develop a game similar to Plants versus Zombies in which we defend our fortress, a tower, from the enemies' attacks and try to defeat them before our fort is destroyed.

Sprites have no intelligence, that's why throughout this chapter we are going to develop a way to make the non-playable characters (the enemies) recognize and follow a path to reach the fortress, and we will also control their attacks by developing a way to load waves of enemies.

As we need to protect ourselves from these attacks, we will learn how to set up the different places where we can build our defenses. We will also provide them with a specific artificial intelligence so they know when enemies...