PacktLib: Cocos2d-X by Example Beginner's Guide

Cocos2d-x by Example Beginner's Guide

Credits

About the Author

About the Reviewers

www.PacktPub.com

Preface

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

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

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

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

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

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

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

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

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

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

Vector Calculations with Cocos2d-x

Vector Calculations with Cocos2d-x

Vector Calculations with Cocos2d-x

Pop Quiz Answers

Pop Quiz Answers

Pop Quiz Answers

Index