cocos2d-x简单绘图(DrawNode)

DrawNode简单绘图示例如下:

 DrawNode* drawNode=DrawNode::create();

    //绘制空心4边形和直线    

    Vec2 point[4];

    point[0] = Vec2(100100);

    point[1] = Vec2(100200);

    point[2] = Vec2(200200);

    point[3] = Vec2(200100);

    drawNode-> drawPolygon (point, 4 , Color4F :: BLUE , 5 , Color4F :: RED );

    

    drawNode->drawLine(Point(100,220),Point(300,220),Color4F::GRAY);

   

   this->addChild(drawNode);

 

drawNode.drawCardinalSpline(config, tension, segments, lineWidth, color)   
//曲线 参数说明: //congfig:点数组 //tension:张力 //segments:段落 //lineWidth:线条宽度 //color:颜色   
drawNode.drawCatmullRom(points, segments, lineWidth, color)  
//同上   
drawNode.drawCircle(center, radius, angle, segments, drawLineToCenter, lineWidth, color)  
//画圆 //参数说明: 原点,半径,弧度,分段(越大越接近圆),原点到弧度的线(boolean),线条宽度,颜色   
drawNode.drawCubicBezier(origin, control1, control2, destination, segments, lineWidth, color) 
//画三次贝塞尔曲线 //
drawNode.drawCubicBezier(cc.p(s.width - 250, 40), cc.p(s.width - 70, 100), cc.p(s.width - 30, 250), cc.p(s.width - 10, s.height - 50),10,1, cc.color(0, 1, 0, 1)); drawNode.drawQuadBezier(origin, control, destination, segments, lineWidth, color)         
//画二次贝塞尔曲线 参考三次贝塞尔曲线
drawNode.drawDot(pos, radius, color)        
//画点 //
drawNode.drawDot(cc.p(60, 100), 20, cc.color(0.5,0.6,0,1));  drawNode.drawDots(points, radius, color)    
//画点  points  点数组   
drawNode.drawPoly(verts, fillColor, lineWidth, color)      
//画多边形
drawNode.drawRect(origin, destination, fillColor, lineWidth, lineColor) 
//画矩形
drawNode.drawSegment(from, to, lineWidth, color)             
//画线段

你可能感兴趣的:(cocos2d-x)