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

Figuring out the geometry


The CCDrawNode class provides just three functions. These functions are drawDot, drawSegment, and drawPolygon, which enable you to draw a color-filled circle, a color-filled segment, and a color-filled polygon with a separate border, respectively. We will write a simple yet extremely resourceful function to help us with the generation of vertices for our game elements. However, before we write this utilitarian function, let's take a closer look at each element and the vertices they contain:

Game element

Visual

Visual with vertices

Player

Enemy

Shield

Bomb

Missile launcher

I have highlighted the vertices on each of these shapes to underline a basic geometrical object that we will use to our advantage in this game—the regular polygon. As most of you may know, a regular polygon is a polygon that is equiangular and equilateral. The interesting thing about a regular polygon is that we can use the parametric equation of a circle to get its vertices...