Book Image

Cocos2d-X Game Development Blueprints

By : Karan Sequeira
Book Image

Cocos2d-X Game Development Blueprints

By: Karan Sequeira

Overview of this book

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

The CCDrawNode class


There are two ways to draw primitive shapes using the functionality provided by Cocos2d-x: one is using the various functions in CCDrawingPrimitives and the other way is using the CCDrawNode class. While the functions defined in CCDrawingPrimitives offer abundant variety, they also incur a performance penalty. The CCDrawNode class, on the other hand, provides just three different drawing functions and batches all its draw calls together to give much better performance. It also inherits from CCNode and thus we can run a few common actions on it! So, we will be using CCDrawNode to render our primitive shapes for this game.

Everything you saw in the preceding screenshot has been drawn using code—except for the score of course. All the main entities of our game, that is, the player, enemies, and power-ups, will inherit from CCDrawNode as you will see shortly. If you're confused about how primitive drawing can yield the preceding results, the following section will make things...