Reprinted please indicate the source:Http://blog.csdn.net/oyangyufu/article/details/25841727
The drawing is as follows:
Program code:
Need to redefine the parent class virtual function draw ()
1. Add the following header files to the HelloWorldScene. h file:
virtual void draw();
2. Definition implementation:
Void HelloWorld: draw () {// add your code .... CHECK_GL_ERROR_DEBUG (); CCSize size = CCDirector, parameter 2: terminal coordinate glLineWidth (1.0f); ccDrawColor4B (0,640, 960); ccDrawLine (ccp (,), ccp (, 0); CHECK_GL_ERROR_DEBUG (); // The line width is 5, the line width is red, and the line width is not transparent. // ccDrawLine parameter 1: Draw the start coordinate, parameter 2: The end coordinate glLineWidth (5.0f); ccDrawColor4B (0,255 ); ccDrawLine (ccp (0, 0,), ccp (960,640); CHECK_GL_ERROR_DEBUG (); // sets the OpenGL vertex size. The default value is the square. // ccDrawLine parameter: draw position // ccPointSize (80); // ccDrawColor4B (255,128,); // set the color // ccDrawPoint (ccp (size. width/2, size. height/2); CHECK_GL_ERROR_DEBUG (); // draw a four-point square CCPoint points [] = {ccp (60, 60), ccp (70, 70), ccp (60, 70 ), ccp (0,255,255,255)}; // four-point location ccPointSize (80); ccDrawColor4B (); ccDrawPoints (points, 4); CHECK_GL_ERROR_DEBUG (); // draw a circle consisting of 10 segments in the middle of the screen, which is not connected to the center of the circle // ccDrawCircle parameter 1: center position; parameter 2: radius; parameter 3: angle; parameter 4: Number of segments; parameter 5: whether to connect glLineWidth (16) to the center of the circle; // The width of ccDrawColor4B (0,255, 0,255); // The color of ccDrawCircle (ccp (size. width/2, size. height/2), 100, 0, 10, false); CHECK_GL_ERROR_DEBUG (); // draw a circle consisting of 50 segments in the middle of the screen, glLineWidth (2), ccDrawColor4B (0,255,255,255), and ccDrawCircle (ccp (size. width/2, size. height/2), 50, CC_DEGREES_TO_RADIANS (90), 50, true); CHECK_GL_ERROR_DEBUG (); // polygon with 5 vertices // ccDrawPoly parameter 1: vertex array; parameter 2: points; parameter 3: whether the image is ccDrawColor4B (255,255, 0,255); glLineWidth (10); CCPoint vertices [] = {ccp (), ccp (50, 50 ), ccp (100,100), ccp (50,100), ccp ()}; ccDrawPoly (vertices, 5, false); CHECK_GL_ERROR_DEBUG (); // a closed polygon with 5 vertices, and fill in the color // ccDrawSolidPoly parameter 1: Dot Array; parameter 2: points; parameter 3: fill color 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 )); // draw a triangle // ccDrawPoly parameter 1: vertex array; parameter 2: points; parameter 3: whether the image is closed (ccDrawColor4B (255, 0,255,255); glLineWidth (2 ); CCPoint vertices2 [] = {ccp (130,230), ccp (130,330), ccp (150,300)}; ccDrawPoly (vertices2, 3, true); CHECK_GL_ERROR_DEBUG (); // draw a selle curve // parameter 1: line start position; parameter 2: line center position; parameter 3: Line End position; parameter 4: number of line segments ccdrawquadbezr (ccp (0,640-100), ccp (size. width/2, size. height/2-100), ccp (960,640-100), 90); CHECK_GL_ERROR_DEBUG (); // draw the curve ccdrawcubicbezr (ccp (size. width/2, size. height/2), ccp (size. width/2 + 100, size. height/2 + 150), ccp (size. width/2 + 200, size. height/2-80), ccp (960,300), 100); CHECK_GL_ERROR_DEBUG (); // draw a yellow oblique rectangle CCPoint vertices3 [] = {ccp (60,160 ), ccp (70,190), ccp (100,190), ccp (90,160)}; ccDrawSolidPoly (vertices3, 4, ccc4f )); // reset the drawing status glLineWidth (1); ccDrawColor4B (255,255,255, 0); ccPointSize (1); CHECK_GL_ERROR_DEBUG ();}