Contents

Contents at a Glance

About the Authors

About the Technical Reviewer

Acknowledgments

Preface

imagesChapter 1: Introduction

What’s New in the Second Edition?

Why Use cocos2d for iOS?

It’s Free

It’s Open Source

It’s Objective, See?

It’s 2D

It’s Got Physics

It’s Less Technical

It’s Still Programming

It’s Got a Great Community

The Future of the cocos2d-iphone Project

Other cocos2d Game Engines

This Book Is for You

Prerequisites

Programming Experience

Objective-C

What You Will Learn

What Beginning iOS Game Developers Will Learn

What iOS App Developers Will Learn

What Cocos2d Developers Will Learn

What’s in This Book

Chapter 2, “Getting Started”

Chapter 3, “Essentials”

Chapter 4, “Your First Game”

Chapter 5, “Game Building Blocks”

Chapter 6, “Sprites In-Depth”

Chapter 7, “Scrolling with Joy”

Chapter 8, “Shoot ’emUp”

Chapter 9, “Particle Effects”

Chapter 10, “Working with Tilemaps”

Chapter 11, “Isometric Tilemaps”

Chapter 12, “Physics Engines”

Chapter 13, “Pinball Game”

Chapter 14, “Game Center”

Chapter 15, “Cocos2d with UIKit Views”

Chapter 16, “Kobold2D Introduction”

Chapter 17, “Conclusion”

Where to Get the Book’s Source Code?

Questions and Feedback

imagesChapter 2: Getting Started

What You Need to Get Started

System Requirements

Register as an iOS Developer

Certificates and Provisioning Profiles

Download and Install the iOS SDK

Download and Install cocos2d

The HelloWorld Application

Locating the HelloWorld Files

Resources

Supporting Files

HelloWorld Classes

Memory Management with cocos2d

Changing the World

What Else You Should Know

The iOS Devices

About Memory Usage

The iOS Simulator

About Logging

Summary

imagesChapter 3: Essentials

The cocos2d Scene Graph

The CCNode Class Hierarchy

CCNode

Working with Nodes

Working with Actions

Scheduled Messages

Director, Scenes, and Layers

The Director

CCScene

Scenes and Memory

Pushing and Popping Scenes

CCTransitionScene

CCLayer

CCSprite

Anchor Points Demystified

Texture Dimensions

CCLabelTTF

Menus

Actions

Interval Actions

Instant Actions

A Note on Singletons in cocos2d

Cocos2d Test Cases

Summary

imagesChapter 4: Your First Game

Step-by-Step Project Setup

Adding the Player Sprite

Accelerometer Input

First Test Run

Player Velocity

Adding Obstacles

Collision Detection

Labels and Bitmap Fonts

Adding the Score Label

Introducing CCLabelBMFont

Creating Bitmap Fonts with Glyph Designer

Simply Playing Audio

Porting to iPad

One Universal App or Two Separate Apps?

Porting to iPad with Xcode 3

Porting to iPad with Xcode 4

Summary

imagesChapter 5: Game Building Blocks

Working with Multiple Scenes

Adding More Scenes

Loading Next Paragraph, Please Stand By

Working with Multiple Layers

How to Best Implement Levels

CCLayerColor

Subclassing Game Objects from CCSprite

Composing Game Objects Using CCSprite

Curiously Cool CCNode Classes

CCProgressTimer

CCParallaxNode

CCRibbon

CCMotionStreak

Summary

imagesChapter 6: Sprites In-Depth

Retina Display

CCSpriteBatchNode

When to Use CCSpriteBatchNode

Demo Projects

Sprite Animations the Hard Way

Animation Helper Category

Working with Texture Atlases

What Is a Texture Atlas?

Introducing TexturePacker

Preparing the Project for TexturePacker

Creating a Texture Atlas with TexturePacker

Using the Texture Atlas with cocos2d

Updating the CCAnimation Helper Category

All into One and One for All

Summary

imagesChapter 7: Scrolling with Joy

Advanced Parallax Scrolling

Creating the Background As Stripes

Re-creating the Background in Code

Moving the ParallaxBackground

Parallax Speed Factors

Scrolling to Infinity and Beyond

Fixing the Flicker

Repeat, Repeat, Repeat

A Virtual Joypad

Introducing SneakyInput

Integrating SneakyInput

Touch Button to Shoot

Skinning the Button

Controlling the Action

Digital Controls

Summary

imagesChapter 8: Shoot 'emUp

Adding the BulletCache Class

What About Enemies?

The Entity Class Hierarchy

The EnemyEntity Class

The EnemyCache Class

The Component Classes

Shooting Things

A Healthbar for the Boss

Summary

imagesChapter 9: Particle Effects

Example Particle Effects

Creating a Particle Effect the Hard Way

Subclassing CCParticleSystem: Point or Quad?

CCParticleSystem Properties

Particle Designer

Introducing the Particle Designer

Using Particle Designer Effects

Sharing Particle Effects

Shoot 'em Up with Particle Effects

Summary

imagesChapter 10: Working with Tilemaps

What Is a Tilemap?

Preparing Images with TexturePacker

Tiled (Qt) Map Editor

Creating a New Tilemap

Designing a Tilemap

Using Orthogonal Tilemaps with Cocos2d

Locating Touched Tiles

An Exercise in Optimization and Readability

Working with the Object Layer

Drawing the Object Layer Rectangles

Scrolling the Tilemap

Summary

imagesChapter 11: Isometric Tilemaps

Designing Isometric Tile Graphics

Isometric Tilemap Editing with Tiled

Creating a New Isometric Tilemap

Creating a New Isometric Tileset

Laying Down Some Ground Rules

Isometric Game Programming

Loading the Isometric Tilemap in Cocos2d

Setup Cocos2d for Isometric Tilemaps

Locating an Isometric Tile

Scrolling the Isometric Tilemap

This World Deserves a Better End

Adding a Movable Player Character

Adding More Content to the Game

Summary

imagesChapter 12: Physics Engines

Basic Concepts of Physics Engines

Limitations of Physics Engines

The Showdown: Box2D vs. Chipmunk

Box2D

The World According to Box2D

Restricting Movement to the Screen

Converting Points

Adding Boxes to the Box2D World

Connecting Sprites with Bodies

Collision Detection

Joint Venture

Chipmunk

Objectified Chipmunk

Chipmunks in Space

Boxing-In the Boxes

Adding Ticky-Tacky Little Boxes

Updating the Boxes' Sprites

A Chipmunk Collision Course

Joints for Chipmunks

Summary

imagesChapter 13: Pinball Game

Shapes: Convex and Counterclockwise

Working with PhysicsEditor

Defining the Plunger Shape

Defining the Table Shapes

Defining the Flippers

Defining the Bumper and Ball

Save and Publish

Programming the Pinball Game

The BodyNode Class

Creating the Pinball Table

Box2D Debug Drawing

Adding the Ball

Forcing the Ball to Move

Adding the Bumpers

The Plunger

The Flippers

Summary

imagesChapter 14: Game Center

Enabling Game Center

Creating Your App in iTunes Connect

Setting Up Leaderboards and Achievements

Creating a Cocos2d Xcode Project

Configuring the Xcode Project

Game Center Setup Summary

Game Kit Programming

The GameKitHelper Delegate

Checking for Game Center Availability

Authenticating the Local Player

Block Objects

Receiving the Local Player's Friend List

Leaderboards

Achievements

Matchmaking

Sending and Receiving Data

Summary

imagesChapter 15: Cocos2d with UIKit Views

What Is Cocoa Touch?

Using Cocoa Touch and cocos2d Together

Why Mix Cocoa Touch with cocos2d?

Limitations of Mixing Cocoa Touch with cocos2d

How Is Cocoa Touch Different from cocos2d?

Alert: Your First UIKit View in cocos2d

Embedding UIKit Views in a cocos2d App

Adding Views in Front of the cocos2d View

Skinning the UITextField with a UIImage

Adding Views Behind the cocos2d View

Adding Views Designed with Interface Builder

Orientation Course on Autorotation

Embedding the cocos2d View in Cocoa Touch Apps

Creating a View-Based Application Project with cocos2d

Designing the User Interface of the Hybrid App

Start Your cocos2d Engine

Stop the cocos2d Engine and Restart It

Changing Scenes

Summary

imagesChapter 16: Kobold2D Introduction

Benefits of Using Kobold2D

Kobold2D Is Ready to Use

Kobold2D Is Free

Kobold2D Is Easy to Upgrade

Kobold2D Provides “Lib Service”

Kobold2D Takes Cross-Platform to Heart

The Kobold2D Workspace

The Hello Kobold2D Template Project

The Hello World Project Files

How Kobold2D Launches an App

The Hello Kobold2D Scene and Layer

Running Hello World with iSimulate

Doodle Drop for Mac with KKInput

Entering the Third Dimension with cocos3d

Changes to the AppDelegate Class

The World According to cocos3d

Adding cocos3d to an Existing Kobold2D Project

Summary

imagesChapter 17: Out of the Ordinary

Additional Resources for Learning and Working

Where to Find Help

Source Code Projects to Benefit From

Cocos2D Podcast

Tools, Tools, Tools

Cocos2d Reference Apps

The Business of Making Games

Working with Publishers

Finding Freelancers

Finding Free Art and Audio

Finding the Tools of the Trade

Marketing

Engaging Players for More Revenue

Summary

imagesIndex

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset