Chapter 8
Shoot ’em Up
What does a game of this kind need above all else? Something to shoot up and bullets to evade. In this chapter, you’ll be adding enemies to the game and even a boss monster.
Both enemies and player will use the new BulletCache class to shoot a variety of bullets from the same pool. The cache class reuses inactive bullets to avoid constantly allocating and releasing bullets from memory. Likewise, enemies will use their own EnemyCache class because they, too, will appear in greater numbers on the screen.
Obviously the player will be able to shoot these enemies. I also introduce the concept of component-based programming, which allows you to extend the game’s actors in a modular way. Besides shooting and moving components, ...
Get Learn cocos2d 2: Game Development for iOS now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.