Cocos2d-X by Example Beginner's Guide


Cocos2d-X by Example Beginner's Guide
eBook: $26.99
Formats: PDF, PacktLib, ePub and Mobi formats
$22.94
save 15%!
Print + free eBook + free PacktLib access to the book: $71.98    Print cover: $44.99
$44.99
save 37%!
Free Shipping!
UK, US, Europe and selected countries in Asia.
Also available on:
Overview
Table of Contents
Author
Support
Sample Chapters
  • Learn to build multi-device games in simple, easy steps, letting the framework do all the heavy lifting
  • Spice things up in your games with easy to apply animations, particle effects, and physics simulation
  • Quickly implement and test your own gameplay ideas, with an eye for optimization and portability
  • Enjoy building the games as much as you will enjoy playing them

Book Details

Language : English
Paperback : 246 pages [ 235mm x 191mm ]
Release Date : April 2013
ISBN : 178216734X
ISBN 13 : 9781782167341
Author(s) : Roger Engelbert
Topics and Technologies : All Books, Game Development, Beginner's Guides, Games, Open Source

Table of Contents

Preface
Chapter 1: Installation
Chapter 2: You plus C++ plus Cocos2d-x
Chapter 3: Your First Game – Air Hockey
Chapter 4: Fun with Sprites – Sky Defense
Chapter 5: On the Line – Rocket Through
Chapter 6: Quick and Easy Sprite – Victorian Rush Hour
Chapter 7: Adding the Looks – Victorian Rush Hour
Chapter 8: Getting Physical – Box2D
Chapter 9: The Last Game – Eskimo
Chapter 10: Code Once. Retire.
Appendix A: Vector Calculations with Cocos2d-x
Appendix B: Pop Quiz Answers
Index
  • Chapter 1: Installation
    • Download and installation
    • Time for action – downloading and installing Cocos2d-x
    • Hello-x World-x
    • Time for action – creating an application
      • The folder structure
      • The iOS linkage classes
      • The AppDelegate class
      • The HelloWorldScene class
      • Who begets whom
  • Further information
  • Time for action – running the test samples
  • The other tools
  • Summary
    • Chapter 2: You plus C++ plus Cocos2d-x
      • Cocos2d-x – an introduction
        • The containers
        • The director and caches
        • Then there is all the other stuff
        • But you don't know C++?
      • The interface
      • Time for action – creating the interface
      • The implementation
      • Time for action – creating the implementation
      • Instantiation and memory management
        • Option 1 – use static methods
        • Option 2 – C++, Cocos2d-x style
      • What you get with CCObject
      • Summary
      • Chapter 3: Your First Game – Air Hockey
        • Game configurations
        • Time for action – creating your game project
        • Time for action – laying down the rules
        • Supporting retina displays
        • Time for action – adding the image files
        • Time for action – adding retina support
        • Adding sound effects
        • Time for action – adding the sound files
        • Extending CCSprite
        • Time for action – adding GameSprite.cpp
        • Time for action – implementing GameSprite
        • The actual game scene
        • Time for action – coding the GameLayer interface
        • Time for action – implementing init()
        • Time for action — handling multi-touches
        • Time for action – adding our main loop
        • Time for action – updating scores
        • Summary
        • Chapter 4: Fun with Sprites – Sky Defense
          • The game – Sky Defense
            • The game settings
            • The start project
            • Adding screen support for a universal app
            • Adding background music
            • Initializing the game
          • Using sprite sheets in Cocos2d-x
            • Batch drawing sprites
          • Time for action – creating a CCSpriteBatchNode
          • Bitmap fonts in Cocos2d-x
          • Time for action – creating bitmap font labels
          • Time for action – adding the final screen sprites
          • Time for action – creating our object pools
          • CCActions in a nutshell
          • Time for action – creating actions with Cocos2d-x
          • Animating a sprite in Cocos2d-x
          • Time for action – creating animations
          • Time to make our game tick!
          • Time for action – handling touches
          • Time for action – starting and restarting the game
          • Time for action – updating the game
          • Time for action – retrieving objects from the pool
          • Play the game!
          • Summary
          • Chapter 5: On the Line – Rocket Through
            • The game – Rocket Through
              • The game settings
              • Play first, work later
              • The start project
              • Screen settings
            • So what are particles?
            • Time for action – creating particle systems
            • Creating the grid
            • Drawing primitives in Cocos2d-x
            • Time for action – let's do some drawing!
            • The Rocket sprite
            • Time for action – updating our Rocket
            • Time for Action – handling touches
            • The game loop
            • Time for action – adding the main loop
            • Kill and reset
            • Time for action – adding our resets and kills
            • Summary
            • Chapter 6: Quick and Easy Sprite – Victorian Rush Hour
              • The game – Victorian Rush Hour
              • The game settings
              • Rapid prototyping with Cocos2d-x
              • Time for action – creating placeholder sprites
              • The Player object
              • The Block object
              • The Terrain object
              • Time for action – coding the player
              • Time for action – coding the Block object
                • Planning the Terrain class
                • Building the Terrain object
              • Time for action – initialising our Terrain class
              • Time for action – initializing our Blocks
              • Time for action – moving and resetting
              • Platform collision logic
              • Time for action – adding collision detection
              • Adding the controls
              • Time for action – handling touches
              • Time for action – coding the main loop
              • Summary
              • Chapter 7: Adding the Looks – Victorian Rush Hour
                • Victorian Rush Hour – the game
                  • New sprites
                  • Animations
                • Texturing our buildings with CCSprites
                • Time for action – texturing the buildings
                • Containers within containers
                • Creating a parallax effect
                • Time for action – creating a parallax effect
                • Adding a menu to our game
                • Time for action – creating CCMenu and CCMenuItem
                • Adding a tutorial to our game
                • Time for action – adding a tutorial
                • Summary
                • Chapter 8: Getting Physical – Box2D
                  • Creating a Box2D project with Cocos2d-x
                  • Time for action – preparing the basic template
                  • So what is a physics engine?
                    • Meet Box2D
                    • Meet the world
                    • Running the simulation
                    • No CCObjects in Box2D
                    • Meet the bodies
                  • Our game – MiniPool
                    • Game settings
                    • CCSprite + b2Body = b2Sprite
                    • Creating the pool table
                    • Creating edges
                    • Creating the ball objects
                    • Creating collision filters
                    • Creating the cue ball
                    • Creating a contact listener
                    • The game controls
                  • Time for action – adding the touch events
                    • The main loop
                  • Time for action – adding the main loop
                    • Adding a timer to our game
                  • Time for action – creating a timer
                  • Summary
                  • Chapter 9: The Last Game – Eskimo
                    • The game – Eskimo
                      • The game settings
                      • How the game is organized
                    • Using CCScenes in Cocos2d-x
                    • Time for action – creating a CCScene transition
                    • Time for action – creating transitions with a singleton CCLayer
                    • Loading external data from a .plist file
                    • Time for action – creating a .plist file
                      • Loading the level data
                    • Time for action – retrieving data from the .plist file
                    • Saving game data
                    • Time for action – storing the completed levels
                    • Using notifications in your game
                    • Time for action – using CCNotificationCenter
                    • Using the accelerometer
                    • Time for action – reading accelerometer data
                    • Reusing b2Bodies
                    • Time for action – changing a b2Body fixture
                    • Summary
                    • Chapter 10: Code Once. Retire.
                      • First, a word on versions and requirements
                        • Requirements
                        • Further steps
                      • Time for action – creating an Android project with Cocos2d-x
                      • Time for action – compiling the code
                      • Using Eclipse
                      • Time for action – installing the C++ compiler
                      • Time for action – adding the Cocos2d-x library to Eclipse
                      • Time for action – opening the project in Eclipse
                        • Running the application
                      • Compiling C++ code in Eclipse
                      • Time for action – compiling our C++ code
                      • Creating a hybrid project
                      • Time for action – creating a hybrid Cocos2d-x project
                      • Creating a Box2D hybrid project
                      • Time for action – creating a Box2D project
                      • Developing a hybrid game
                      • Summary
                      • Appendix A: Vector Calculations with Cocos2d-x
                        • What are vectors?
                          • The vector methods
                        • Using ccp helper methods
                          • Rotating the rocket around a point
                          • Using the dot product of vectors
                          • Moving from pixel-based speed to angular-based speed

                          Roger Engelbert

                          Roger Engelbert is a game developer with over ten years of experience in developing online games. He grew up surrounded by video games and thinks of classic, 8-bit arcade titles as a form of art. He is the author behind the blog Done With Computers, which is chock-full of tutorials on game development and design. Roger sincerely hopes to soon live in a world where people of all ages will be given the knowledge and opportunity to experience the joy of building their own games.
                          Sorry, we don't have any reviews for this title yet.

                          Code Downloads

                          Download the code and support files for this book.


                          Submit Errata

                          Please let us know if you have found any errors not listed on this list by completing our errata submission form. Our editors will check them and add them to this list. Thank you.


                          Errata

                          - 3 submitted: last submission 24 Sep 2013

                          Errata type: Technical | Errata date: 28 May 2013

                          The examples in this book and the accompanied code files use version 2.04 of the Cocos2d-x framework in every project. In case you find any discrepancies in the code or if you want to run the code examples in the current version 2.1.3 of the framework, have a look at this post: http://rengelbert.com/blog/cocos2d-x-book-update

                           

                          Errata Type: Code related | Page number :43 It is: player->setVector(ccp(0,0));); It should be : player->setVector(ccp(0,0));

                          Errata Type: Others | Page number: 14 

                          After step 2 while running the TestCpp project, the build target "TestCpp" must be selected first to get the project to execute.  
                          
                          

                          Sample chapters

                          You can view our sample chapters and prefaces of this title on PacktLib or download sample chapters in PDF format.

                          Frequently bought together

                          Cocos2d-X by Example Beginner's Guide +    OpenGL Development Cookbook =
                          50% Off
                          the second eBook
                          Price for both: £24.65

                          Buy both these recommended eBooks together and get 50% off the cheapest eBook.

                          What you will learn from this book

                          • Make your games look cooler with particle effects
                          • Create place holder sprites to quickly test your game ideas
                          • Load external data into your games
                          • Build game menus and tutorials
                          • Implement game-wide events with notifications
                          • Create a dash game with a textured terrain
                          • Build a Box2D puzzle game with multiple levels
                          • Create a hybrid iOS and Android project

                          In Detail

                          Cocos2d-x is the C++ port of arguably the most popular open source 2D framework in the world. Its predecessor was limited to the Apple family but with Cocos2d-x you can take your applications to all major app stores, with minimum extra work. Give your games a larger target audience with almost no extra hassle.

                          "Cocos2d-X by Example Beginner's Guide" allows you to build your own cross platform games using all the benefits of a time tested framework, plus the elegance and simplicity of C++.

                          Each of the six games developed in this book will take you further on the road to becoming an expert game developer with no fuss and plenty of fun.

                          Follow six tutorials for six very different games that leverage the ease of Cocos2D-X and its quick implementation, moving from simple ideas to more advanced topics in game development.

                          In easy-to-follow steps, the book teaches you how to take full advantage of the framework by adding animations and special effects, implementing a physics engine, and optimizing your games.

                          Prepare your project for multiple platforms and learn how to take your game concepts to completion.

                          "Cocos2d-X by Example Beginner's Guide" will present to you, in six different games, the topics necessary to build some of the most popular and fun types of games today.

                          Approach

                          Get to grips with Cocos2D-X using step-by-step examples. Roger Engelbert will have you smiling throughout and learning valuable information at every turn.

                          Who this book is for

                          If you have brilliant ideas for amazing games and want to bring them to life, then this book is what you need. Work through easy-to-follow examples and learn exactly what you need to know to make your games a reality. No programming experience necessary!

                          Code Download and Errata
                          Packt Anytime, Anywhere
                          Register Books
                          Print Upgrades
                          eBook Downloads
                          Video Support
                          Contact Us
                          Awards Voting Nominations Previous Winners
                          Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
                          Resources
                          Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software