Book Image

Cocos2d Game Development Blueprints

By : Jorge Jordán
Book Image

Cocos2d Game Development Blueprints

By: Jorge Jordán

Overview of this book

Table of Contents (15 chapters)
Cocos2d Game Development Blueprints
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

CCSpriteBatchNode


To improve the tasks involved in drawing a texture on the screen, we can take advantage of the CCSpriteBatchNode class, which wraps the multiple sprite renders in just one execution.

The only objects that can be added to CCSpriteBatchNode are CCSprite instances or any other class derived from CCSprite. There is another restriction: every child in the batch must make use of the same texture, but we will see in the next section that this isn't in fact a weakness.

Let's learn how to use this class by adding several enemies to the scene, so let's add the image that will represent them:

  1. Right-click on the Resources group and select Add Files to "HumanApocalypse"….

  2. Look for the human-ipad.png and human-ipadhd.png files in the Resources folder.

  3. Be sure that Copy items into destination group's folder (if needed) is selected and click on Add.

Define a constant value for the number of human enemies that will be loaded by adding the following line to GameScene.m after the imports section...