<1>重写virtual void draw()方法
切记,在draw函数中,绘制图形,draw函数中绘制图形的语句你不能放在一个自己写的函数中,不然画不出来.
<2>代码示例
void HelloWorld::draw() { CCLog("draw called"); //-new-// CCSize mysize=CCDirector::sharedDirector()->getWinSize(); //画个猥琐的直线 ccDrawColor4B(255,255,255,130); glLineWidth(3); ccDrawLine(ccp(100,200),ccp(mysize.width-100,200)); //再画个可爱的圈圈 ccDrawColor4B(255,255,100,190); glLineWidth(3); ccDrawCircle(ccp(mysize.width/2,mysize.height/2),100,0,360,1,2,1); //再来画个点 ccDrawColor4B(255,25,200,250); glLineWidth(3); ccPointSize(10); ccDrawPoint(ccp(mysize.width/2,mysize.height/2)); //再来画个空心矩形 ccDrawColor4B(24,25,200,140); glLineWidth(3); ccDrawRect(ccp(100,100),ccp(300,200)); //再来个实心的 ccDrawSolidRect(ccp(110,210),ccp(310,110),ccc4f(255,255,255,0.5f)); //再来画个空心多边形 ccDrawColor4B(240,225,100,130); glLineWidth(3); CCPoint Polyarray[]={ccp(20,100),ccp(50,40),ccp(250,420),ccp(510,450),ccp(210,140)}; ccDrawPoly(Polyarray,5,1); //再来个实心的多边形 CCPoint Polyarray2[]={ccp(120,150),ccp(150,420),ccp(350,120),ccp(310,250),ccp(320,170)}; ccDrawSolidPoly(Polyarray2,5,ccc4f(142,245,70,0.3f)); //绘制平面贝赛尔曲线 ccDrawColor4B(100,100,100,255); ccDrawQuadBezier(ccp(0,320),ccp(160,100),ccp(480,320),100); //绘制立体贝赛尔曲线 ccDrawColor4B(200,200,200,255); ccDrawCubicBezier(ccp(0,0),ccp(160,300),ccp(320,20),ccp(480,320),100); //-new-// }