You are previewing Creating Games with cocos2d for iPhone 2.
O'Reilly logo
Creating Games with cocos2d for iPhone 2

Book Description

"

Master cocos2d through building nine complete games for the iPhone.

  • Games are explained in detail, from the design decisions to the code itself

  • Learn to build a wide variety of game types, from a memory tile game to an endless runner

  • Use different design approaches to help you explore the cocos2d framework

In Detail

Cocos2d for iPhone is a simple (but powerful) 2D framework that makes it easy to create games for the iPhone. There are thousands of games in the App Store already using cocos2d. Game development has never been this approachable and easy to get started.

"Creating Games with cocos2d for iPhone 2" takes you through the entire process of designing and building nine complete games for the iPhone, iPod Touch, or iPad using cocos2d 2.0. The projects start simply and gradually increase in complexity, building on the lessons learned in previous chapters. Good design practices are emphasized throughout.

From a simple match game to an endless runner, you will learn how to build a wide variety of game styles.

You will learn how to implement animation, actions, create “artificial randomness”, use the Box2D physics engine, create tile maps, and even use Bluetooth to play between two devices.

"Creating games with cocos2d for iPhone 2" will take your game building skills to the next level.

"

Table of Contents

  1. Creating Games with cocos2d for iPhone 2
    1. Table of Contents
    2. Creating Games with cocos2d for iPhone 2
    3. Credits
    4. About the Author
    5. About the Reviewers
    6. www.PacktPub.com
      1. Support files, eBooks, discount offers, and more
        1. Why Subscribe?
        2. Free Access for Packt account holders
    7. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code
        2. Downloading the color images of this book
        3. Errata
        4. Piracy
        5. Questions
    8. 1. Thanks for the Memory Game
      1. The project is...
      2. Let's build a menu
        1. Where is the scene?
        2. Building the playfield
      3. We need sprites
        1. Building a sprite sheet
      4. On to the playfield
        1. Creating the playfield header
        2. Creating the playfield layer
      5. The flow of the game
      6. A stack of tiles
        1. The memory tile class
        2. Loading tiles
        3. Drawing tiles
      7. Adding interactivity
        1. Checking for matches
      8. Scoring and excitement
      9. Animating the score
        1. Adding lives and game over
        2. Bringing it all together
        3. It's quiet...too quiet
      10. Summary
    9. 2. Match 3 and Recursive Methods
      1. The project is…
      2. Basic gem interaction
        1. The MAGem header
        2. The MAGem class
        3. Generating gems
      3. Building the playfield
      4. Checking for matches
        1. Collecting touches
        2. Moving gems
      5. Checking moves
        1. Removing gems
        2. The update method
      6. Predictive logic
      7. Artificial randomness
      8. Summary
    10. 3. Thumping Moles for Fun
      1. The project is…
        1. Design approach
        2. Designing the spawn
        3. Portrait mode
        4. Custom TTF fonts
      2. Defining a molehill
        1. Building the mole
      3. Making a molehill
        1. Drawing the ground
      4. Mole spawning
        1. Special moles
        2. Moving moles
        3. The animation cache
      5. Combining actions and animation
        1. Simultaneous actions
        2. Deleting moles
      6. Touching moles
      7. Tying it together
        1. Scoring the mole
      8. Summary
    11. 4. Give a Snake a Snack…
      1. The project is…
        1. Design approach
      2. Building a better snake
        1. Anatomy of a snake segment
        2. Dissecting the snake
        3. Building the head
        4. Building the body segments
      3. Moving the snake
        1. Turning the snake
        2. Death of a snake
      4. Building the environment
        1. Outer walls
        2. Inner walls
        3. Building snake food
      5. Collisions and eating
      6. Levels and difficulties
      7. The main loop
        1. Level-up checking
        2. Dead mice
      8. But…how do we control the snake?
      9. Summary
    12. 5. Brick Breaking Balls with Box2D
      1. The project is…
      2. Box2D – a primer
        1. Box2D – what is it?
          1. Basic parts of Box2D
      3. On to the game!
        1. World building
        2. On the edge
        3. Having a ball
      4. Setting everything in motion
        1. Collision handling
        2. Losing your ball
        3. Destruction
      5. Paddling around
        1. Paddle fixture
        2. Touching the paddle
      6. Storing player data
        1. Displaying player data
      7. Building bricks
        1. Loading a plist
        2. Picking a pattern
      8. Breaking bricks, for real
      9. Power-ups, good and bad
        1. Picking up power-ups
        2. Paddle deformation
        3. Restoring the paddle
        4. Multiball
        5. Losing lives with multiball
      10. Summary
    13. 6. Cycles of Light
      1. The game is…
      2. Design review
      3. Let's build a bike
        1. CLBike header
        2. CLBike implementation
        3. Bike rotation
        4. Turning the bike
      4. Building walls
        1. Boundary walls
        2. Bike walls
        3. Bike integration
      5. Bike movement
      6. Control buttons
        1. Touching buttons
        2. Flashing with blocks
        3. Finishing the buttons
      7. Building the background grid
        1. Drawing the grid
        2. The second grid
        3. Moving grids
        4. The glScissor
      8. The playfield
        1. Generating the bikes
        2. Collision handling
        3. Making it move
        4. Crashing bikes
      9. Bluetooth multiplayer
        1. Peer Picker
        2. Session callbacks
        3. Sending messages
        4. Receiving data
        5. Upgrading our bikes
        6. Why send moves?
      10. Summary
    14. 7. Playing Pool, Old School
      1. The game is…
      2. Overall design
      3. Building the table
        1. The Box2D world
        2. Building the rails
        3. Building pockets
        4. Creating the cue stick
      4. Loading the rules
        1. Rules.plist
      5. Rack 'em up
        1. Building the rack
      6. Player HUD
        1. Displaying messages
      7. Collision handling
      8. Building the control base
        1. One-touch control
        2. Two-touch control
      9. The rules engine
      10. Putting balls back
      11. Checking the table
      12. The playfield init method
      13. Summary
    15. 8. Shoot, Scroll, Shoot Again
      1. The game is…
      2. Design review
      3. Tiled – a primer
        1. Drawing the ground
        2. Logic layers
        3. Spawn layer
        4. Understanding TMX format
        5. Creating an HD map
      4. Implementing the tilemap
      5. Adding our hero
        1. Focus on the hero
      6. Controlling the hero with SneakyJoystick
        1. Tilt controls
        2. Interpreting the controls
      7. Building the HUD
      8. Scene construction
      9. Tile helper methods
        1. Tile self-identification
      10. Smarter hero walking
      11. Time for bullets
        1. TDBullet class
      12. Building the enemy
        1. Adding the enemies
      13. Collision handling
        1. Everybody gets hit
      14. Game over, man
      15. Smarter enemies
        1. Code not covered here
      16. Summary
    16. 9. Running and Running and Running...
      1. The game is...
      2. Design review
      3. Building the ground
        1. ERTile class
        2. Adding gap tiles
        3. Scrolling the tiles
      4. Parallax background
      5. Our hero
        1. Animation loading
        2. Updating the hero
      6. Touch controls
      7. Shooting bullets
      8. Enemies everywhere
      9. Collision handling
        1. Getting shot with particles
        2. Death of hero
      10. Summary
    17. Index