You are previewing Cocos2d-x Game Development Essentials.
O'Reilly logo
Cocos2d-x Game Development Essentials

Book Description

Create iOS and Android games from scratch using Cocos2d-x

In Detail

Cocos2d-x is the C++ port of the most popular open source 2D framework in the world. Cocos2d-x is an amazing open source game engine that allows developers to exploit their existing C++, Lua, and JavaScript knowledge for cross-platform deployment into iOS, Android, Windows Phone, BlackBerry, Tizen, and HTML5, saving you time, effort, and cost.

You will learn the essentials of Cocos2d-x through examples, by creating a game from scratch. The book starts with adding scenes and menus to the game. Furthermore, you can learn more about the varied features such as scene transitions, game sprites, moving the spaceship, and adding audio to make your game livelier. By the end of the book, you will be able to solve problems that may arise during the entire game development phase.

What You Will Learn

  • Set up Cocos2d-x to create games
  • Create a new project in Cocos2d-x
  • Learn to run a project on iOS and Android platforms
  • Implement the core game structure using Cocos2d-x tools and techniques
  • Add gameplay using general coding practices and built-in functions within Cocos2d-x
  • Manipulate the game items to provide gameplay using Cocos2d-x actions
  • Overcome common problems faced during the game development phase with Cocos2d-x
  • Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at If you purchased this book elsewhere, you can visit and register to have the files e-mailed directly to you.

    Table of Contents

    1. Cocos2d-x Game Development Essentials
      1. Table of Contents
      2. Cocos2d-x Game Development Essentials
      3. Credits
      4. About the Authors
      5. About the Reviewers
        1. Support files, eBooks, discount offers, and more
          1. Why subscribe?
          2. Free access for Packt account holders
      7. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Downloading the example code
          2. Errata
          3. Piracy
          4. Questions
      8. 1. Setting Up
        1. What is Cocos2d-x?
        2. Setting up the project
        3. Housekeeping
          1. Refactoring HelloWorldScene.h
          2. Refactoring HelloWorldScene.cpp
          3. Refactoring AppDelegate.cpp
        4. Implementing multiresolution support
        5. Summary
      9. 2. Adding Scenes
        1. Creating new scenes
          1. Refactoring GameScene.h
          2. Refactoring GameScene.cpp
        2. Manipulating scenes
          1. Code for the Main Menu scene
          2. Code for the Game scene
          3. Code for the Game Over scene
          4. Code for the Pause scene
        3. Summary
      10. 3. Adding Game Menus
        1. Setting up the menu
        2. Coding the menus in the Main Menu scene
        3. Coding the menus in the Game scene
        4. Coding the menus in the Pause scene
        5. Coding the menus in the Game Over scene
        6. Summary
      11. 4. Scene Transitions
        1. The fade transition
        2. Additional transitions
        3. Summary
      12. 5. The Game Sprites
        1. Adding the Main Menu sprites
        2. Adding the Game Over sprites
        3. Adding the Pause sprites
        4. Adding the Game sprites
        5. Summary
      13. 6. Implementing Actions
        1. Actions
          1. Moving
          2. Jumping
          3. Bezier actions
          4. Placing
          5. Scaling
          6. Rotation
          7. Tinting
          8. Fading
          9. Skewing
          10. Repeating
          11. Sequencing
        2. Animation
        3. Summary
      14. 7. Moving the Space Pod Using Touch
        1. The general process for setting up touches
        2. Single-touch events
        3. Multi-touch events
        4. Summary
      15. 8. Collision Detection
        1. Collision detection
        2. Player collision detection
          1. Setting up collision detection
          2. Implementing the collision detection
        3. Summary
      16. 9. Adding Audio to the Game
        1. Loading and playing sound effects
        2. Adding sound effects
          1. Adding the menu-button-click sound effect
          2. Adding the crash sound effect
          3. Additional sound effect features
        3. Loading and playing background music
          1. Adding background music
          2. Additional background music features
        4. Summary
      17. 10. Implementing Accelerometer Support
        1. Setting up the accelerometer
        2. Summary
      18. 11. Problem Solving and What's Next
        1. Problem solving
          1. Removing debug information
          2. Positioning on different devices
          3. Moving an object on different devices
          4. Trouble generating new projects
          5. Reusing actions
          6. Sequencing actions
          7. Running your application on simulators
          8. Application size
          9. Breakpoints
        2. What's next?
      19. Index