Home > Store

Learning Cocos2D: A Hands-On Guide to Building iOS Games with Cocos2D, Box2D, and Chipmunk, Rough Cuts

Rough Cuts

  • Available to Safari Subscribers
  • About Rough Cuts
  • Rough Cuts are manuscripts that are developed but not yet published, available through Safari. Rough Cuts provide you access to the very latest information on a given topic and offer you the opportunity to interact with the author to influence the final publication.

Not for Sale

Description

  • Copyright 2012
  • Dimensions: 7" x 9"
  • Pages: 640
  • Edition: 1st
  • Rough Cuts
  • ISBN-10: 0-13-218088-X
  • ISBN-13: 978-0-13-218088-7

This is the Rough Cut version of the printed book.

Build the Next Great iOS Game with Cocos2D!

Cocos2D is the powerhouse framework behind some of the most popular games in the App Store. If you’ve played Tiny Wings, Angry Birds, Mega Jump, Trainyard, or even Super Turbo Action Pig, then you’ve played a game that uses Cocos2D or Box2D physics. The beauty of Cocos2D is its simplicity. It’s easy to become overwhelmed when you start developing an iOS game, especially if you look at things like OpenGL ES, OpenAL, and other lower level APIs. Writing a game for the iPhone and iPad does not have to be that difficult, and Cocos2D makes game development fun and easy.

Learning Cocos2D walks you through the process of building Space Viking (which is free on the App Store), a 2D scrolling game that leverages Cocos2D, Box2D, and Chipmunk. As you build Space Viking, you’ll learn everything you need to know about Cocos2D so you can create the next killer iOS game.

Download the free version of Space Viking from the App Store today! Help Ole find his way home while learning how to build the game.

As you build Space Viking, you’ll learn how to

  • Install and configure Cocos2D so it works with Xcode 4
  • Build a complete 2D action adventure game with Cocos2D
  • Add animations and movement to your games
  • Build your game’s main menu screen for accessing levels
  • Use Cocos2D’s Scheduler to make sure the right events happen at the right times
  • Use tile maps to build scrolling game levels from reusable images
  • Add audio and sound effects with CocosDenshion—Cocos2D’s sound engine
  • Add gravity, realistic collisions, and even ragdoll effects with Box2D and Chipmunk physics engines
  • Add amazing effects to your games with particle systems
  • Leverage Game Center in your game for achievements and leader boards
  • Squeeze the most performance from your games along with tips and tricks

Sample Content

Table of Contents

Preface xxi

Acknowledgments xxxiii

About the Authors xxxvii

Part I: Getting Started with Cocos2D 1

Chapter 1: Hello, Cocos2D 3

Downloading and Installing Cocos2D 4

Creating Your First Cocos2D HelloWorld 6

For the More Curious: Understanding the Cocos2D HelloWorld 11

Getting CCHelloWorld on Your iPhone or iPad 20

Summary 22

Challenges 22

Chapter 2: Hello, Space Viking 23

Creating the SpaceViking Project 23

Creating the Space Viking Classes 24

Creating the Background Layer 26

The Gameplay Layer: Adding Ole the Viking to the Game 29

The GameScene Class: Connecting the Layers in a Scene 31

Commanding the Cocos2D Director 34

Adding Movement 35

Texture Atlases 44

For the More Curious: Testing Out CCSpriteBatchNode 52

Fixing Slow Performance on iPhone 3G and Older Devices 53

Summary 54

Challenges 54

Chapter 3: Introduction to Cocos2D Animations and Actions 57

Animations in Cocos2D 57

Space Viking Design Basics 62

Actions and Animation Basics in Cocos2D 66

Using Property List Files to Store Animation Data 67

Organization, Constants, and Common Protocols 69

The GameObject and GameCharacter Classes 74

Summary 82

Challenges 82

Chapter 4: Simple Collision Detection and the First Enemy 83

Creating the Radar Dish and Viking Classes 83

Creating the Viking Class 90

Final Steps 105

Summary 112

Challenges 113

Part II: More Enemies and More Fun 115

Chapter 5: More Actions, Effects, and Cocos2D Scheduler 117

Power-Ups 118

Enemy Robot 125

Adding the PhaserBullet 137

GameplayLayer and Viking Updates 141

For the More Curious: Effects in Cocos2D 145

Summary 149

Exercises and Challenges 149

Chapter 6: Text, Fonts, and the Written Word 151

CCLabelTTF 151

Understanding Anchor Points and Alignment 153

CCLabelBMFont 155

Using Glyph Designer 156

Using the Hiero Font Builder Tool 156

For the More Curious: Live Debugging 160

Summary 165

Challenges 165

Part III: From Level to Game 167

Chapter 7: Main Menu, Level Completed, and Credits Scenes

Updates

Submit Errata

More Information