What this book covers
In this book, you will find eight chapters, each covering a different genre of video games. The aim of the book is that you learn the features of Cocos2d at the same time as you discover the singularities of several games that have been or are currently successful in the video game industry.
Chapter 1, Sprites, Sounds, and Collisions, covers the first steps of developing with Cocos2d v3.0. This chapter will guide you through how to create a horizontal-scroll game in which you will create sprites from an image. You will also learn how to move sprites across the screen thanks to executing actions, and in case it's needed, how to manage collisions. Also, you will learn how to show score labels and how to play background music and sound effects. The best of all, this game will be available on both iPhone and iPad devices.
Chapter 2, Explosions and UFOs, shows the process of developing a classic shoot 'em up in which the accelerometer takes control of the movement. In this game, you will learn to load and set up particle systems such as explosions and fire and draw primitives (lines, circles, and squares) on a CCNode instance. In addition, you will be introduced to the parallax effect and you will implement it in the game.
Chapter 3, Your First Online Game, teaches you the development of a turn-based game with the particularity that it will allow you to play against another player thanks to the configuration of Game Center in your game. Also, you will learn how to drag, scale, and rotate sprites and how to include labels using bitmap fonts. As this is a turn-based game, you will learn to include timers to control each player's turn.
Chapter 4, Beat All Your Enemies Up, takes you back to the 80s and 90s as you learn to develop one of the classic arcade genres: the beat 'em up. In this chapter, you will learn to create an iPad-only game in which players will move thanks to a track pad you will develop. As this kind of game demands that the characters perform different movements, you will learn to animate the sprites using several image files to optimize sprites' management. You will also will learn how to use sprite sheets.
Chapter 5, Scenes at the Highest Level, covers the development of a brain game in which you will create a tutorial so players can learn the basics of the game. You will learn how to load data from external files to configure the different scenes and how to create transitions between these scenes. In order to keep the user's data, you will learn how to save this information.
Chapter 6, Physics Behavior, introduces you to the physics world but the high-level one because you will learn to take advantage of Chipmunk, a physics engine available in Cocos2d. You will learn to set up and run a Chipmunk simulation and to create and reuse bodies. Collisions are managed by this library too, so you will learn how to use collision filters and listeners to create a sports game.
Chapter 7, Jump and Run, creates a platform game that will handle specific collision logic and manage multiple touches. Also, you will learn how to use multiple sprites to texture varied terrain and you will learn how to add a menu to the game so players can configure some setups.
Chapter 8, Defend the Tower, teaches you how to create a tower defense game and you will learn how to provide Artificial Intelligence to non-playable characters. In addition, you will develop a pathfinder algorithm so these NPCs know which path is best for them. Through this chapter, you will also learn to include notifications and in-app purchases.