Free Sample
+ Collection

Cocos2d-X by Example Beginner's Guide

Beginner's Guide
Roger Engelbert

With Cocos2d-x you don’t have to be a programming whiz to be a genius at game design. This tutorial will help unleash your inner creativity with lots of fun tutorials. Get the know-how to build great cross-platform 2D games.
$26.99
$44.99
RRP $26.99
RRP $44.99
eBook
Print + eBook

Want this title & more?

$12.99 p/month

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.

Book Details

ISBN 139781782167341
Paperback246 pages

About This Book

  • 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

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!

Table of Contents

Chapter 1: Installation
Download and installation
Time for action – downloading and installing Cocos2d-x
Hello-x World-x
Time for action – creating an application
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 interface
Time for action – creating the interface
The implementation
Time for action – creating the implementation
Instantiation and memory management
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
Using sprite sheets in Cocos2d-x
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
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
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
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?
Our game – MiniPool
Time for action – adding the touch events
Time for action – adding the main loop
Time for action – creating a timer
Summary
Chapter 9: The Last Game – Eskimo
The game – Eskimo
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
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
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
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

What You Will Learn

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

Authors

Read More

Recommended for You

Learning Cocos2d-x Game Development
$ 26.99
Cocos2d-x by Example: Beginner's Guide - Second Edition
$ 35.99
Cocos2d-x Game Development Essentials
$ 13.99
Building Android Games with Cocos2d-x
$ 19.99
Creating Games with cocos2d for iPhone 2
$ 26.99