Cocos2d uses openGLES, which is a graphics library that enables objects to be displayed onscreen. In fact, all the drawing that we have done until now uses this library. Cocos2d also gives you basic access to glPrimitives, which can be used to create basic shapes, such as circles, squares, rectangles, and so on.
Let's take a look at a few of the examples now. We will begin by creating a simple circle.
Right after adding the
hero node, we will add the following code:
//drawDotNode CCDrawNode* dotNode = [CCDrawNode node]; CCColor* red = [CCColorcolorWithRed:1.0fgreen:0.0fblue:0.0f]; [dotNodedrawDot:CGPointMake(winSize.width/2, winSize.height/2) radius: 10.0fcolor:red]; [selfaddChild:dotNode];