void HelloWorld::draw() { CCSize size = CCDirector::sharedDirector()->getWinSize(); // 设置颜色 ccDrawColor4B(255, 0, 255, 0); // 设置宽度 glLineWidth(3); // 绘制一条直线 起点到终点的位置 ccDrawLine(ccp(0, 0), ccp(size.width*0.5, size.height*0.5)); ccDrawColor4B(225, 255, 0, 0); // 设置像素尺寸 ccPointSize(20); // 绘制一个点 ccDrawPoint(ccp(size.width*0.5, size.height*0.5)); ccDrawColor4B(0, 25, 255, 0); // 绘制圆形 ccDrawCircle(ccp(size.width*0.5, size.height*0.5), 50, CC_DEGREES_TO_RADIANS(90),50, false); ccDrawCircle(ccp(size.width*0.5, size.height*0.5), 50, CC_DEGREES_TO_RADIANS(45), 6, false); ccDrawColor4B(225, 0, 0, 0); glLineWidth(5); // 绘制多边形 CCPoint ve[]= { ccp (70 ,150),ccp (150,150),ccp (100,200) }; ccDrawPoly(ve,3, true); ccDrawColor4B(0, 0, 0, 255); // 绘制填充的多边形 CCPoint vi[]={ ccp (0,120) ,ccp (50 ,120) ,ccp (50 ,170) ,ccp (25,200) }; ccDrawSolidPoly(vi, 4, ccc4f(0.5f, 0.5f, 1, 1)); ccDrawColor4B(0, 0, 255, 100); // 绘制贝塞尔曲线 ccDrawQuadBezier(ccp(0,size.height), ccp(size.width*0.5,size.height*0.5), ccp (size.width,size.height), 50); // 绘制立体的贝塞尔曲线 ccDrawCubicBezier(ccp(size.height*0.5,size.height*0.5), ccp(size.width+20,size.height), ccp(size.width+20,size.height+60),ccp (size.width,size.height), 50); // 绘制填充矩形 ccDrawSolidRect(ccp(240,50), ccp(300,10), ccc4f(0, 177, 177, 255)); // 绘制空心矩形 ccDrawRect(ccp(30,130), ccp (20,20)); }