Learning iPhone Game Development with Cocos2D 3.0

Harness the power of Cocos2D to create your own stunning and engaging games for iOS

Learning iPhone Game Development with Cocos2D 3.0

Beginner's Guide
Kirill Muzykov

Harness the power of Cocos2D to create your own stunning and engaging games for iOS
$23.99
$39.99
RRP $23.99
RRP $39.99
eBook
Print + eBook
$12.99 p/month

Want this title & more? 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.
+ Collection
Free Sample

Book Details

ISBN 139781782160144
Paperback434 pages

About This Book

  • Find practical solutions to many real-world game development problems
  • Create games from start to finish by writing code and following detailed step-by-step instructions
  • Full of illustrations and diagrams, practical examples, and tips for deeper understanding of game development in Cocos2D for iPhone

Who This Book Is For

If you want to learn how to make games using the Cocos2D framework, this book is for you. If you would like to build a good foundation for a career in game development as an independent game developer or at a game studio, or if you just want to make games as a hobby, then you'll love this book. You should have some basic programming experience with Objective-C and Xcode. To run the code in this book, you will also need an Intel-based Macintosh running OS X Mountain Lion (or later).

Table of Contents

Chapter 1: All About Cocos2D
Game engines
Why Cocos2D?
Games created with Cocos2D
Summary
Chapter 2: Hello Cocos2D
Starting with Xcode
Integrating Cocos2D with Xcode
Time for action – downloading and installing Cocos2D
Creating a Hello World project
Time for action – creating a new project from a template
Time for action – running the project on the simulator
Modifying the project
Time for action – creating a new scene
Time for action – displaying the world
Time for action – displaying the welcome label
Reviewing Cocos2D distribution
Time for action – running tests
Summary
Chapter 3: Cocos2D – Under the Hood
Reviewing Cocos2D
Summary
Chapter 4: Rendering Sprites
Creating the game project
Time for action – creating the Cocohunt Xcode project
Time for action – creating GameScene
Adding sprites to your game
Time for action – adding the background sprite
Time for action – adding the player character
Time for action – fixing z-order
Adding more sprites and moving them
Time for action – adding birds
Time for action – making the bird move
Understanding debug FPS labels
Spritesheets and animation
Time for action – creating a spritesheet
Time for action – modifying the game to use spritesheets
Time for action – animating the birds
Summary
Chapter 5: Starting the Action
Making the hunter aim and shoot
Time for action – handling touches
Time for action – aiming at the touch position
Time for action – shooting the arrow
Adding more birds to the GameScene class
Time for action – adding more birds
Time for action – detecting if the arrow hits the bird
Winning, losing, and other states
Time for action – using states for the bird's life cycle
Time for action – animating the shooting and limiting the shooting rate
Time for action – winning or losing the game
Improving the gameplay
Time for action – limiting the aiming range
Time for action – alternative control using a gyroscope
Summary
Chapter 6: Rendering Text
The easy way – CCLabelTTF
Time for action – adding labels
Time for action – updating labels
Using bitmap fonts for better performance
Time for action – creating a bitmap font using Glyph Designer
Time for action – adding hit points
Time for action – adding the win and lose labels
Summary
Chapter 7: Animations and Particle Systems
Using frame-based animation
Time for action – exploding coconut
Animating using actions
Time for action – hitting the bird animation
Skeletal animation
Creating particle systems for advanced effects
Time for action – adding the feathers explosion
Time for action – adding a fire to the scene
Time for action – using Particle Designer
Summary
Chapter 8: Adding Sound Effects and Music
Creating AudioManager and playing sound effects
Time for action – adding the AudioManager class
Time for action – finding and playing our first sound effect
Time for action – playing the remaining sound effects
Music and background sounds
Time for action – adding background sounds
Time for action – adding music
Enhancing Cocohunt sound effects
Time for action – preloading sound effects
Time for action – playing a sound at position
Summary
Chapter 9: User Interface and Navigation
Using buttons
Time for action – adding menu buttons
Time for action – toggling sound and music
Time for action – storing settings in NSUserDefaults
Navigating between scenes
Time for action – pushing AboutScene
Time for action – using more transitions
Time for action – using the scroll view to select levels
Creating modal dialogs and using text input
Time for action – pausing the game with a pause dialog
Time for action – restarting and exiting the game
Time for action – displaying stats when losing and winning
Entering and displaying highscores
Time for action – displaying highscores with CCTableView
Time for action – using the text field
Summary
Chapter 10: Physics
Creating a physics world
Time for action – creating a game level with physics
Time for action – adding ground to the scene
Time for action – adding the hunter
Time for action – fixing the hunter movement
Detecting and filtering collisions
Time for action – detecting and ignoring collisions
Time for action – filtering collisions using a collision mask
Time for action – filtering collisions using collision groups
Applying forces and impulses and using joints
Time for action – launching stones
Time for action – adding angry birds
Summary
Chapter 11: Working with Tile Maps
Creating tile maps
Time for action – creating a tileset
Time for action – creating a tile map
Time for action – creating the Retina version of the tile map
Using the tile maps
Time for action – creating TilemapScene
Time for action – moving and following the bird
Time for action – using parallax scrolling
Summary

What You Will Learn

  • Install Cocos2D and create projects using Cocos2D Xcode templates
  • Understand the Cocos2D architecture and its main classes
  • Render images and text, move and animate them
  • Control your game using touches and a gyroscope
  • Create a user interface and navigate between game screens
  • Use the physics engine to apply forces and detect collisions
  • Add sounds and music and change playback properties
  • Integrate your game with Game Center and make In-App purchases

In Detail

Cocos2D-iPhone (Cocos2D-Swift) is a robust yet simple-touse 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 Cocos2D offers.

This book will set you on the fast-track to game development with Cocos2D for iPhone. You will start by reviewing the basic classes and hierarchy, dive deep into animations and game flow, and finish by creating a complete game with UI using some advanced techniques.

You will begin the book with an empty Cocos2D project and build on it until you end up with a complete game. The book will teach you how to work on game logic, handling user input, controlling the character, and playing audio. Later, in the final part of the book, we'll have a working game on our hands, and we'll see how we can improve the game further

Authors

Table of Contents

Chapter 1: All About Cocos2D
Game engines
Why Cocos2D?
Games created with Cocos2D
Summary
Chapter 2: Hello Cocos2D
Starting with Xcode
Integrating Cocos2D with Xcode
Time for action – downloading and installing Cocos2D
Creating a Hello World project
Time for action – creating a new project from a template
Time for action – running the project on the simulator
Modifying the project
Time for action – creating a new scene
Time for action – displaying the world
Time for action – displaying the welcome label
Reviewing Cocos2D distribution
Time for action – running tests
Summary
Chapter 3: Cocos2D – Under the Hood
Reviewing Cocos2D
Summary
Chapter 4: Rendering Sprites
Creating the game project
Time for action – creating the Cocohunt Xcode project
Time for action – creating GameScene
Adding sprites to your game
Time for action – adding the background sprite
Time for action – adding the player character
Time for action – fixing z-order
Adding more sprites and moving them
Time for action – adding birds
Time for action – making the bird move
Understanding debug FPS labels
Spritesheets and animation
Time for action – creating a spritesheet
Time for action – modifying the game to use spritesheets
Time for action – animating the birds
Summary
Chapter 5: Starting the Action
Making the hunter aim and shoot
Time for action – handling touches
Time for action – aiming at the touch position
Time for action – shooting the arrow
Adding more birds to the GameScene class
Time for action – adding more birds
Time for action – detecting if the arrow hits the bird
Winning, losing, and other states
Time for action – using states for the bird's life cycle
Time for action – animating the shooting and limiting the shooting rate
Time for action – winning or losing the game
Improving the gameplay
Time for action – limiting the aiming range
Time for action – alternative control using a gyroscope
Summary
Chapter 6: Rendering Text
The easy way – CCLabelTTF
Time for action – adding labels
Time for action – updating labels
Using bitmap fonts for better performance
Time for action – creating a bitmap font using Glyph Designer
Time for action – adding hit points
Time for action – adding the win and lose labels
Summary
Chapter 7: Animations and Particle Systems
Using frame-based animation
Time for action – exploding coconut
Animating using actions
Time for action – hitting the bird animation
Skeletal animation
Creating particle systems for advanced effects
Time for action – adding the feathers explosion
Time for action – adding a fire to the scene
Time for action – using Particle Designer
Summary
Chapter 8: Adding Sound Effects and Music
Creating AudioManager and playing sound effects
Time for action – adding the AudioManager class
Time for action – finding and playing our first sound effect
Time for action – playing the remaining sound effects
Music and background sounds
Time for action – adding background sounds
Time for action – adding music
Enhancing Cocohunt sound effects
Time for action – preloading sound effects
Time for action – playing a sound at position
Summary
Chapter 9: User Interface and Navigation
Using buttons
Time for action – adding menu buttons
Time for action – toggling sound and music
Time for action – storing settings in NSUserDefaults
Navigating between scenes
Time for action – pushing AboutScene
Time for action – using more transitions
Time for action – using the scroll view to select levels
Creating modal dialogs and using text input
Time for action – pausing the game with a pause dialog
Time for action – restarting and exiting the game
Time for action – displaying stats when losing and winning
Entering and displaying highscores
Time for action – displaying highscores with CCTableView
Time for action – using the text field
Summary
Chapter 10: Physics
Creating a physics world
Time for action – creating a game level with physics
Time for action – adding ground to the scene
Time for action – adding the hunter
Time for action – fixing the hunter movement
Detecting and filtering collisions
Time for action – detecting and ignoring collisions
Time for action – filtering collisions using a collision mask
Time for action – filtering collisions using collision groups
Applying forces and impulses and using joints
Time for action – launching stones
Time for action – adding angry birds
Summary
Chapter 11: Working with Tile Maps
Creating tile maps
Time for action – creating a tileset
Time for action – creating a tile map
Time for action – creating the Retina version of the tile map
Using the tile maps
Time for action – creating TilemapScene
Time for action – moving and following the bird
Time for action – using parallax scrolling
Summary

Book Details

ISBN 139781782160144
Paperback434 pages
Read More

Recommended for You