You are previewing Cocos2d for iPhone 0.99 Beginner's Guide.
O'Reilly logo
Cocos2d for iPhone 0.99 Beginner's Guide

Book Description

Make mind-blowing 2D games for iPhone with this fast, flexible, and easy-to-use framework!

  • 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

  • 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.

    This book is a practical guide for building your own fun and exciting iPhone games in no time using the cocos2d for iPhone framework.

    Table of Contents

    1. Cocos2d for iPhone 0.99 Beginner's Guide
      1. Cocos2d for iPhone 0.99 Beginner's Guide
      2. Credits
      3. About the Author
      4. About the Reviewers
      5. Preface
        1. What this book covers
        2. What you need for this book
        3. Who is this book for?
        4. What games will you be making in this book?
          1. Coloured Stones
          2. AerialGun
          3. Totem balance
        5. Cocos2d open source and commercial projects
          1. ABC123
          2. DeBlock
          3. Gorillas
          4. Grabbed
          5. Pusher
          6. Thrown
          7. Tweejump
          8. Sapus Tongue
        6. Conventions
        7. Reader feedback
        8. Customer support
          1. Errata
          2. Piracy
          3. Questions
      6. 1. Getting Started with Cocos2d
        1. Downloading Cocos2d for iPhone
        2. Time for action - opening the samples project
          1. What just happened?
          2. Have a go hero - trying out the rest of the samples
        3. Installing the templates
        4. Time for action - installing the templates
          1. What just happened?
        5. Creating a new project from the templates
        6. Time for action - creating a HelloCocos2d project
          1. What just happened?
        7. Managing the game with the CCDirector
          1. Types of CCDirectors
        8. Time for action - taking a first look at the HelloCocos2dAppDelegate
          1. What just happened?
          2. Scene management
        9. Doing everything with CCNodes
        10. Time for action - peeking at the HelloWorldScene class
          1. What just happened
          2. CCNodes properties
          3. Handling CCNodes
          4. Have a go hero - doing more with the HelloWorldScene Class
        11. Checking your timing
        12. Time for action - using timers to make units shoot each second
          1. What just happened?
          2. Delaying a method call
        13. Time for action - destroying your units
          1. What just happened?
        14. Debugging cocos2d applications
        15. Time for action - checking Cocos2d debug messages
          1. What just happened?
        16. Time for action - checking deallocing messages
          1. What just happened?
        17. Time for action - knowing your errors
          1. What just happened?
        18. Time for action - removing debug messages
          1. What just happened?
        19. Summary
      7. 2. Playing with Sprites
        1. Making a puzzle game
        2. Beginning a new project
        3. Time for action - creating a new project
          1. What just happened?
          2. Displaying images with CCSprites
          3. Time for action - adding a background image to the game
            1. What just happened?
            2. Creating CCSprites
              1. Pixel formats
              2. More ways of creating CCSprites
          4. Time for action - creating the Stone class
            1. What just happened?
          5. Creating the game board
          6. Time for action - placing stones in the grid
            1. What just happened?
            2. Have a go hero - finding another way to place the stones
          7. Interacting with sprites
          8. Time for action - registering the stones for receiving touches
            1. What just happened?
          9. Time for action - handling touches for swapping stones
            1. What just happened?
            2. Have a go hero - canceling the swap
          10. Time for action - swapping the stones around
            1. What just happened?
            2. Have a go hero - doing more with the CCTouchDispatcher
          11. Time for action - checking for matches
            1. What just happened?
          12. Making them fall!
          13. Time for action - refilling the grid
            1. What just happened?
            2. Analyzing the logic
          14. Playing with CCSprite's properties
          15. Time for action - making a time bar
            1. What just happened?
          16. Changing a sprite's texture at runtime
          17. Time for action - changing textures on the fly
            1. What just happened?
            2. The CCTextureCache
            3. Pop Quiz - sprites
          18. Using Spritesheets
          19. Time for action - creating sprites from Spritesheets
            1. What just happened?
            2. Have a go hero - changing the rest of the elements
          20. Creating Spritesheets with zwoptex
          21. Time for action - creating more colored stones with Spritesheets
            1. What just happened?
          22. Preloading images
          23. Time for action - preloading your images
            1. What just happened?
          24. Making OpenGl Calls
          25. Time for action - selecting a stone for swapping
            1. What just happened?
          26. Summary
      8. 3. Let's Do Some Actions
        1. Basic actions
        2. Time for action - animating the stone falling
          1. What just happened?
          2. Using other basic actions
        3. Time for action - destroying stones with actions
          1. What just happened?
        4. Time for action - tinting the time bar
          1. What just happened?
          2. Have a go hero - applying actions all over the game
        5. Composition actions
        6. Time for action - making a nice disappear effect
          1. What just happened?
          2. More composition actions
        7. Time for action - making stones fall and grow
          1. What just happened?
        8. Time for action - animating the grid
          1. What just happened?
          2. Pop Quiz - actions
        9. Ease actions
        10. Time for action - modifying animations with ease actions
          1. What just happened?
        11. Effect actions
        12. Time for action - making the background shake when matching five stones
          1. What just happened?
          2. Applying a single action to multiple CCNodes
        13. Special actions
        14. Time for action - ready, set, go!
          1. What just happened?
          2. Have a go hero - telling the player that he lost
          3. Using CCCallFuncND
        15. Time for action - telling the player he lost
          1. What just happened?
        16. Animations
        17. Time for action - animating the stones
          1. What just happened?
          2. CCSpriteFrame and the CCSpriteFrameCache
          3. The CCAnimation class
          4. Have a go hero - breaking the stones
        18. Summary
      9. 4. Pasting Labels
        1. Using CCLabels
        2. Time for action - first time tutorials
          1. What just happened?
          2. Have a go hero - improving the Tutorial class
        3. Displaying texts with CCLabelAtlas
        4. Time for action - displaying and updating scores with CCLabelAtlas
          1. What just happened?
        5. Creating texts with CCBitmapFontAtlas
        6. Time for action - showing feedback
          1. What just happened?
        7. Time for action - running actions on texts
          1. What just happened?
        8. Making your own BitmapFontAtlas with BM Font tool
        9. Time for action - creating your own Bitmap font
          1. What just happened?
          2. Pop Quiz
        10. Wrapping up the game
        11. Summary
      10. 5. Surfing through Scenes
        1. Aerial Gun, a vertical shooter game
        2. Creating new scenes
        3. Time for action - creating the splash and main menu scene
          1. What just happened?
        4. Transitioning through scenes
        5. Time for action - moving through scenes in a nice way
          1. What just happened?
        6. Implementing the game logic
          1. Preparing for the game
          2. Making a hero
        7. Time for action - creating the hero class
          1. What just happened?
          2. Making yourself some enemies
        8. Time for action - throwing enemies at your hero
          1. What just happened?
          2. Have a go hero - enhancing the enemies behavior
          3. Forging some bullets
        9. Time for action - creating and reusing bullets
          1. What just happened?
          2. Have a go hero - upgrading your firepower
        10. Handling accelerometer input
        11. Time for action - moving your hero with the accelerometer
          1. What just happened?
        12. Handling touches on layers
        13. Time for action - firing the bullets
          1. What just happened?
        14. Detecting collisions
        15. Time for action - shooting down your enemies
          1. What just happened?
        16. Time for action - losing your life
          1. What just happened?
        17. Adding more layers to scenes
        18. Time for action - creating a HUD to display lives and the score
          1. What just happened?
          2. Have a go hero - creating a Game Over screen
        19. Time for action - creating a pause menu
          1. What just happened?
        20. Time for action - pausing the game while inactive
          1. What just happened?
          2. Pop Quiz - scenes and layers
        21. Summary
      11. 6. Menu Design
        1. Creating a simple menu
        2. Time for action - adding a menu with texts to the main scene
          1. What just happened?
          2. Have a go hero - moving CCMenuItems around
        3. Using image menu items
        4. Time for action - adding a difficulty selection screen
          1. What just happened?
        5. Animating menu items
        6. Time for action - animating the main menu
          1. What just happened?
        7. Using toggle menu items
        8. Time for action - creating the options menu
          1. What just happened?
          2. Pop Quiz - menu items
        9. Saving and loading preferences
        10. Time for action - persisting options data
          1. What just happened?
          2. Have a go hero - loading and using your saved data
        11. Summary
      12. 7. Implementing Particle Systems
        1. Taking a look at the prebuilt particle systems
        2. Time for action - running the particle test
          1. What just happened?
        3. Time for action - analyzing the ParticleMeteor system
          1. What just happened?
          2. Particle system properties
        4. Implementing particle systems in your game using Gravity mode
          1. CCPointParticleSystem
          2. CCQuadParticleSystem
        5. Time for action - making bombs explode
          1. What just happened?
          2. Have a go hero - giving the sense of motion
        6. Using the radius mode
        7. Time for action - hurting your enemies
          1. What just happened?
          2. Changing the way particle systems move
        8. Using Particle Designer to create particle systems
        9. Time for action - creating a smoke trail
          1. What just happened?
          2. Pop Quiz - particle systems
        10. Summary
      13. 8. Familiarizing Yourself with Tilemaps
        1. Using tilemaps
        2. Creating tilemaps with Tiled
        3. Time for action - creating your first map
          1. What just happened?
        4. Loading tilemaps in Cocos2d
        5. Time for action - using tilemaps in Cocos2d
          1. What just happened?
        6. Time for action - running actions on layers
          1. What just happened?
        7. Time for action - reaching the end of the level
          1. What just happened?
        8. Time for action - fixing black gaps and glitches
          1. What just happened?
          2. Pop Quiz
        9. Using layers to hold objects
        10. Time for action - adding object layers in tiled
          1. What just happened?
        11. Time for action - retrieving objects in Cocos2d
          1. What just happened?
          2. Have a go hero - creating enemies spawn points
        12. Summary
      14. 9. Playing Sounds with CocosDenshion
        1. What is CocosDenshion?
        2. Getting started with sounds
        3. Time for action - using SimpleAudioEngine
          1. What just happened?
          2. Methods for handling sound effects
        4. Time for action - playing background music with SimpleAudioEngine
          1. What just happened?
          2. Methods for handling background music
          3. Have a go hero - turning the music down
        5. Using CDSoundEngine
        6. Time for action - setting it up
          1. What just happened?
        7. Time for action - playing sound effects for explosions
          1. What just happened?
        8. Time for action - loading effects asynchronously with CDSoundEngine
          1. What just happened?
        9. Time for action - playing background music with CDAudioManager
          1. What just happened?
          2. Pop Quiz - playing with CDAudioManager
        10. Summary
      15. 10. Using Physics Engines
        1. A word about physics engines
          1. Box2d
          2. Chipmunk
          3. So, which one should I use?
        2. Totem balance, a physical game
        3. Time for action - taking a look at the Chipmunk template
          1. What just happened?
          2. Understanding cpBodies and cpShapes
        4. Preparing the game
        5. Bringing objects to life
          1. The Totem
        6. Time for action - creating a poly-shaped object
          1. What just happened?
        7. Time for action - creating the goal platform
          1. What just happened?
          2. Removable blocks
        8. Time for action - building blocks
          1. What just happened?
          2. Have a go hero - creating other complex shapes
        9. Time for action - destroying shapes with touch
          1. What just happened?
        10. Collision callbacks
        11. Time for action - losing the game
          1. What just happened?
        12. Time for action - winning the game
          1. What just happened?
        13. Placing static shapes
          1. Pop Quiz - physics engines
        14. Summary
      16. 11. Integrating OpenFeint
        1. Signing up and downloading the SDK
        2. Time for action - signing up and downloading the SDK
          1. What just happened?
        3. Integrating OpenFeint into your game
        4. Time for action - making OpenFeint work
          1. What just happened?
        5. Time for action - displaying the OpenFeint dashboard
          1. What just happened?
        6. Adding leaderboards to your game
        7. Time for action - creating a leaderboard
          1. What just happened?
          2. Have a go hero - customizing leaderboard look and feel
        8. Adding achievements to your game
        9. Time for action - creating an achievement
          1. What just happened?
          2. Pop Quiz - OpenFeint
        10. Submitting your game for OpenFeint approval
        11. Summary
      17. A. Pop Quiz - Answers
        1. Chapter 2:
          1. Playing with Sprites
        2. Chapter 3:
          1. Let’s do some actions
        3. Chapter 4:
          1. Pasting labels
        4. Chapter 5:
          1. Surfing through scenes
        5. Chapter 6:
          1. Menu design
        6. Chapter 7:
          1. Implementing particle systems
        7. Chapter 8:
          1. Familiarizing yourself with tilemaps
        8. Chapter 9:
          1. Playing sounds with CocosDenshion
        9. Chapter 10:
          1. Using physics engine
        10. Chapter 11:
          1. Integrating OpenFeint