Free Sample
+ Collection

Cocos2d for iPhone 0.99 Beginner's Guide

Beginner's Guide
Pablo Ruiz

Make mind-blowing 2D games for iPhone with this fast, flexible, and easy-to-use framework!
RRP $23.99
RRP $39.99
Print + eBook

Want this title & more?

$16.99 p/month

Subscribe to PacktLib

Enjoy full and instant access to over 2000 books and videos – you’ll find everything you need to stay ahead of the curve and make sure you can always get the job done.

Book Details

ISBN 139781849513166
Paperback368 pages

About This Book

  • A cool guide to learning cocos2d with iPhone to get you into the iPhone game industry quickly
  • Learn all the aspects of cocos2d while building three different games
  • Add a lot of trendy features such as particles and tilemaps to your games to captivate your players
  • Full of illustrations, diagrams, and tips for building iPhone games, with clear step-by-step instructions and practical examples

Who This Book Is For

If you want to get into the iPhone industry and have your games compete with the best, this book is for you. You should have some basic programming experience with Objective-C and a good understanding of OOP. A little experience of game programming in any language is welcome but not a must.

Table of Contents

Chapter 1: Getting Started with Cocos2d
Downloading Cocos2d for iPhone
Time for action – opening the samples project
Installing the templates
Time for action – installing the templates
Creating a new project from the templates
Time for action – creating a HelloCocos2d project
Managing the game with the CCDirector
Time for action – taking a first look at the HelloCocos2dAppDelegate
Doing everything with CCNodes
Time for action – peeking at the HelloWorldScene class
Checking your timing
Time for action – using timers to make units shoot each second
Time for action – destroying your units
Debugging cocos2d applications
Time for action – checking Cocos2d debug messages
Time for action – checking deallocing messages
Time for action – knowing your errors
Time for action – removing debug messages
Chapter 2: Playing with Sprites
Making a puzzle game
Beginning a new project
Time for action – creating a new project
Displaying images with CCSprites
Time for action – adding a background image to the game
Time for action – creating the Stone class
Creating the game board
Time for action – placing stones in the grid
Interacting with sprites
Time for action – registering the stones for receiving touches
Time for action – handling touches for swapping stones
Time for action – swapping the stones around
Time for action – checking for matches
Making them fall!
Time for action – refilling the grid
Playing with CCSprite's properties
Time for action – making a time bar
Changing a sprite's texture at runtime
Time for action – changing textures on the fly
Using Spritesheets
Time for action – creating sprites from Spritesheets
Creating Spritesheets with zwoptex
Time for action – creating more colored stones with Spritesheets
Preloading images
Time for action – preloading your images
Making OpenGl Calls
Time for action – selecting a stone for swapping
Chapter 3: Let's Do Some Actions
Basic actions
Time for action – animating the stone falling
Time for action – destroying stones with actions
Time for action – tinting the time bar
Composition actions
Time for action – making a nice disappear effect
Time for action – making stones fall and grow
Time for action – animating the grid
Ease actions
Time for action – modifying animations with ease actions
Effect actions
Time for action – making the background shake when matching five stones
Special actions
Time for action – ready, set, go!
Time for action – telling the player he lost
Time for action – animating the stones
Chapter 4: Pasting Labels
Using CCLabels
Time for action – first time tutorials
Displaying texts with CCLabelAtlas
Time for action – displaying and updating scores with CCLabelAtlas
Creating texts with CCBitmapFontAtlas
Time for action – showing feedback
Time for action – running actions on texts
Making your own BitmapFontAtlas with BM Font tool
Time for action – creating your own Bitmap font
Wrapping up the game
Chapter 5: Surfing through Scenes
Aerial Gun, a vertical shooter game
Creating new scenes
Time for action – creating the splash and main menu scene
Transitioning through scenes
Time for action – moving through scenes in a nice way
Implementing the game logic
Time for action – creating the hero class
Time for action – throwing enemies at your hero
Time for action – creating and reusing bullets
Handling accelerometer input
Time for action – moving your hero with the accelerometer
Handling touches on layers
Time for action – firing the bullets
Detecting collisions
Time for action – shooting down your enemies
Time for action – losing your life
Adding more layers to scenes
Time for action – creating a HUD to display lives and the score
Time for action – creating a pause menu
Time for action – pausing the game while inactive
Chapter 6: Menu Design
Creating a simple menu
Time for action – adding a menu with texts to the main scene
Using image menu items
Time for action – adding a difficulty selection screen
Animating menu items
Time for action – animating the main menu
Using toggle menu items
Time for action – creating the options menu
Saving and loading preferences
Time for action – persisting options data
Chapter 7: Implementing Particle Systems
Taking a look at the prebuilt particle systems
Time for action – running the particle test
Time for action – analyzing the ParticleMeteor system
Implementing particle systems in your game using Gravity mode
Time for action – making bombs explode
Using the radius mode
Time for action – hurting your enemies
Using Particle Designer to create particle systems
Time for action – creating a smoke trail
Chapter 8: Familiarizing Yourself with Tilemaps
Using tilemaps
Creating tilemaps with Tiled
Time for action – creating your first map
Loading tilemaps in Cocos2d
Time for action – using tilemaps in Cocos2d
Time for action – running actions on layers
Time for action – reaching the end of the level
Time for action – fixing black gaps and glitches
Using layers to hold objects
Time for action – adding object layers in tiled
Time for action – retrieving objects in Cocos2d
Chapter 9: Playing Sounds with CocosDenshion
What is CocosDenshion?
Getting started with sounds
Time for action – using SimpleAudioEngine
Time for action – playing background music with SimpleAudioEngine
Using CDSoundEngine
Time for action – setting it up
Time for action – playing sound effects for explosions
Time for action – loading effects asynchronously with CDSoundEngine
Time for action – playing background music with CDAudioManager
Chapter 10: Using Physics Engines
A word about physics engines
Totem balance, a physical game
Time for action –taking a look at the Chipmunk template
Preparing the game
Bringing objects to life
Time for action – creating a poly-shaped object
Time for action – creating the goal platform
Time for action – building blocks
Time for action – destroying shapes with touch
Collision callbacks
Time for action –losing the game
Time for action –winning the game
Placing static shapes
Chapter 11: Integrating OpenFeint
Signing up and downloading the SDK
Time for action – signing up and downloading the SDK
Integrating OpenFeint into your game
Time for action – making OpenFeint work
Time for action – displaying the OpenFeint dashboard
Adding leaderboards to your game
Time for action – creating a leaderboard
Adding achievements to your game
Time for action – creating an achievement
Submitting your game for OpenFeint approval

What You Will Learn

  • Learn the basics of the most popular 2D framework for iPhone
  • Packed with tips and tricks for using this framework
  • Use actions and effects to make your graphics stand out
  • Implement particles to make your players vibrate
  • Make huge levels with Tilemaps
  • Play sounds in many different ways
  • Give your game real-life physics
  • Integrate OpenFeint, the most popular social gaming network, with your game

In Detail

Cocos2d for iPhone is a robust but simple-to-use 2D game framework for iPhone. If you are just starting with game programming, cocos2d will enable you to make your first game in no time. Even if you are a seasoned game developer, you will still be able to benefit from what it offers. Yet beginning with cocos2d for iPhone may be an arduous task without a proper guide.

Cocos2d for iPhone 0.99 Beginner’s Guide will help you to learn how to make games with cocos2d from the ground up. You will learn all the key concepts of the framework and game programming in general while building your first game using this exciting platform.

You will start by learning the basics of cocos2d then you will learn how to enhance your game with a lot of cool features and eye candy. After spending a little time learning the basics, you will jump straight into action. The book will then teach you to build games from scratch and how to add animations, sounds, and particle effects to them. Then you will be guided to have your game behave as in real life by using a physics engine. After reading Cocos2d for iPhone 0.99 Beginner's Guide, you will be able to write your own games for iPhone while using all the elements Pros use. There are a lot of examples, images, and diagrams to get you up to speed in no time.


Read More

Recommended for You