Drawing, In the cocos2d-x comes TestCpp, including drawing points, straight lines, polygon (filled and not filled), circles, besell curves. First, override the draw method of the parent class in the HelloWorld class [cpp] virtual void draw (); Delete the class capacity in init in the source file, the init method should be executed first than draw, which will overwrite the effect we have drawn. After deletion, the init method is as follows [cpp] bool HelloWorld: init () {bool bRet = false; do {CC_BREAK_IF (! CCLayer: init (); bRet = true;} while (0); return bRet;} bool HelloWorld: init () {bool bRet = false; do {CC_BREAK_IF (! CCLayer: init (); bRet = true;} while (0); return bRet;} Then write the following code in the draw method: [cpp] void HelloWorld :: draw () {CHECK_GL_ERROR_DEBUG ();/* draws a straight line. The default width is 1, the color is white, opaque, and glable (GL_LINE_SMOOTH ); by default, the backend width is not set */glLineWidth (1.0f); ccDrawColor4B (255,255,255,255); ccDrawLine (ccp (480,320), ccp (); CHECK_GL_ERROR_DEBUG (); glLineWidth (5.0f); ccDrawColor4B (0,255, 0,320); ccDrawLine (ccp (128), ccp (); CHECK_GL_ERROR_DEBUG (); // ccPointSize ); this is useless. ccDrawColor4B (0,255,255,128); ccDrawPoint (ccp (240,200); CHECK_GL_ERROR_DEBUG (); // draw CCPoint points [] = {ccp (60, 60) together ), ccp (0,255,255,255), ccp (60, 70), ccp ()}; ccPointSize (4); ccDrawColor4B (); ccDrawPoints (points, 4 ); // draw a green circle with 10 segments glLineWidth (1); ccDrawColor4B (0,255, 0,255); ccDrawCircle (ccp (240,160), // center 100, // radius 1, // if the line from the center of the circle to the circle is set to true, // This value is the angle of the line, 0 is horizontal to left, counter-clockwise 360, // how many parts of the circle are divided into true // whether there is a line from the center of the circle to the circle); // draw a polygon ccDrawColor4B (255,255, 0,255); glLineWidth (1 ); CCPoint vertices [] = {ccp (100,100), ccp (50, 50), ccp (50,100), ccp (), ccp ()}; ccDrawPoly (vertices, 5, true // closed); // filled polygon glLineWidth (1); CCPoint filledVertices [] = {ccp (0,120), ccp (50,120), ccp (50,170 ), ccp (25,200), ccp (0,170)}; ccDrawSolidPoly (filledVertices, 5, ccc4f (0.5f, 0.5f, 1, 1) // fill color ); // The beiser curve ccDrawColor4B (255,255, 0,255); ccdrawcubicbeier (ccp (0, 0), // The starting point ccp (50, 50), // The Control Point ccp (250,100 ), // Control Point ccp (300,300), // target point 100 // the curve obtained by dividing into segments); // restore the default glLineWidth (1); ccDrawColor4B (255,255,255,255 ); ccPointSize (1);} void HelloWorld: draw () {CHECK_GL_ERROR_DEBUG ();/* draws a straight line. The default width is 1, and the color is white and opaque, glable (GL_LINE_SMOOTH); by default, the back end is no longer set the color width */glLineWidth (1.0f); ccDrawColor4B (255,255,255,255); ccDrawLine (ccp (0, 0 ), ccp (480,320); CHECK_GL_ERROR_DEBUG (); glLineWidth (5.0f); ccDrawColor4B (0,255, 0,320); ccDrawLine (), ccp (, 0); CHECK_GL_ERROR_DEBUG (); // ccPointSize (128); this is useless. ccDrawColor4B (0,255,255,128); ccDrawPoint (ccp (240,200); CHECK_GL_ERROR_DEBUG (); // draw CCPoint points [] = {ccp (60, 60), ccp (70, 70), ccp (60, 70), ccp ()}; ccPointSize (4 ); ccDrawColor4B (0,255,255,255); ccDrawPoints (points, 4); // draw a green circle with 10 segments glLineWidth (1); ccDrawColor4B (0,255, 0,255); ccDrawCircle (ccp (240,160 ), // center 100, // radius 1, // if the link from the center to the circle is set to true, // This value is the angle of the line, 0 is horizontal to left, counter-clockwise 360, // how many parts of the circle are divided into true // whether there is a line from the center to the circle); // draw a polygon ccDrawColor4B (255,255, 0,255); glLineWidth (1); CCPoint vertices [] = {ccp (100,100), ccp (50, 50), ccp (50,100), ccp (), ccp )}; ccDrawPoly (vertices, 5, true // closed or not); // filled polygon glLineWidth (1); CCPoint filledVertices [] = {ccp (0,120), ccp (50,120 ), ccp (50,170), ccp (25,200), ccp (0,170)}; ccDrawSolidPoly (filledVertices, 5, ccc4f (0.5f, 0.5f, 1, 1) // fill color ); // The beiser curve ccDrawColor4B (255,255, 0,255); ccdrawcubicbeier (ccp (0, 0), // The starting point ccp (50, 50), // The Control Point ccp (250,100 ), // Control Point ccp (300,300), // target point 100 // the curve obtained by dividing into segments); // restore the default glLineWidth (1); ccDrawColor4B (255,255,255,255 ); ccPointSize (1);} the comments in the Code are clearly explained. The following is: