You are previewing Building Android Games with Cocos2d-x.
O'Reilly logo
Building Android Games with Cocos2d-x

Book Description

Learn to create engaging and spectacular games for Android using Cocos2d-x

In Detail

Cocos2d-x is a multi-platform C++ gaming framework in active development maintained by Chukong technologies. It wraps all the essential elements needed for creating a game, making the task of game building very developer-friendly.

Starting with a vital primer to get you up and running with your development environment, you will quickly dive in to exploring the latest version of this framework. You will understand major framework improvements to render objects at lightning speed, extend and maintain code easily, and improve the label API to add great functionality such as glow, shadows, and outlines to labels.

Through the creation of a real game, you will explore the core components of development including Physics, enabling you to create realistic sprite movements, and particle systems to dynamically simulate explosions, fire, rain, and smoke, as well as exploring the sound engine to make your game more robust. Finish by integrating Cocos2d-x C++ code with native Android code to launch games with the classic Java Android application.

What You Will Learn

  • Set up your work environment

  • Learn how to create graphic elements and animate them

  • Use the built-in physics engine to make your games more realistic

  • Manage user interaction using the touch and accelerometer capabilities

  • Boost your game's visual appeal by learning to add text and using true type and bitmap fonts

  • Enhance your game by adding sound effects and background music

  • Discover how to add rich explosion effects using particle systems

  • Add native Java code to your Android game

  • 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 http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

    Table of Contents

    1. Building Android Games with Cocos2d-x
      1. Table of Contents
      2. Building Android Games with Cocos2d-x
      3. Credits
      4. Foreword
      5. About the Author
      6. About the Reviewers
      7. www.PacktPub.com
        1. Support files, eBooks, discount offers, and more
          1. Why subscribe?
          2. Free access for Packt account holders
      8. 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
      9. 1. Setting Up Your Development Environment
        1. Cocos2d-x overview
        2. Setting up Java
        3. Setting up the Android SDK
          1. Downloading the Android SDK
          2. Downloading Eclipse
          3. Setting up the Eclipse ADT plugin
        4. Setting up the Android Native Development Kit
        5. Setting up Apache Ant
        6. Setting up Python
        7. Setting up Cocos2d-x
          1. Creating your first project
          2. Setting up the Eclipse IDE
        8. Template code walk-through
          1. Java classes
          2. Android application configuration
          3. C++ classes
          4. Scenes
        9. Summary
      10. 2. Graphics
        1. Creating scenes
          1. Understanding Layers
          2. Using the director
        2. Pausing the game
          1. Organizing our resources files
          2. Creating our pause scene header file
          3. Creating the pause scene implementation file
            1. Transitions
        3. Understanding nodes
        4. Understanding sprites
          1. Creating sprites
          2. Positioning sprites
            1. Setting anchor points
            2. Understanding the Cocos2d-x coordinate system
            3. Adding sprites to the scene
            4. Positioning sprites outside the visible area
            5. Positioning the player sprite
        5. Understanding actions
          1. Moving sprites
          2. Creating sequences
        6. Animating sprites
          1. Improving performance with sprite sheets
        7. Game menus
          1. Handling multiple screen resolutions
        8. Putting everything together
        9. Summary
      11. 3. Understanding Game Physics
        1. Setting up the physics world
        2. Collision detection
        3. Handling gravity
          1. Handling physics properties
            1. Applying velocity
            2. Linear damping
            3. Applying force
            4. Applying impulse
            5. Applying torque
        4. Putting everything together
        5. Summary
      12. 4. User Input
        1. Understanding the Event Dispatcher mechanism
        2. Handling the touch event
          1. Handling multi-touch events
        3. Handling accelerometer events
        4. Keeping the screen alive
        5. Handling the Android back key pressed event
        6. Putting everything together
        7. Summary
      13. 5. Handling Text and Fonts
        1. Creating TrueType font labels
          1. Creating our GameOverScene
          2. Calling our GameOverScene when a player loses
          3. Customizing the GameOverScene
          4. Adding label effects
        2. Creating system fonts
        3. Creating bitmap font labels
          1. Adding more bombs to our game
        4. Putting everything together
        5. Summary
      14. 6. Audio
        1. Playing background music and sound effects
        2. Modifying audio properties
          1. Handling audio when leaving the game
        3. The new audio engine
          1. New features included in the new audio engine
        4. Adding a mute button to our game
        5. Putting everything together
        6. Summary
      15. 7. Creating Particle Systems
        1. Creating collections of the Cocos2d-x objects
          1. Exploding bombs
        2. Adding particle systems to our game
        3. Configuring the particle systems
        4. Creating customized particle systems
        5. Putting everything together
        6. Summary
      16. 8. Adding Native Java Code
        1. Understanding the Cocos2d-x structure for the Android platform
        2. Understanding the JNI capabilities
        3. Adding Java code to the Cocos2d-x game
        4. Adding ads to the game by inserting Java code
        5. Configuring the environment
        6. Modifying the Android manifest
          1. Adding the Java code
        7. Putting everything together
        8. Summary
      17. Index