DrawNode简单绘图示例如下:
DrawNode* drawNode=DrawNode::create();
//绘制空心4边形和直线
Vec2point[4];
point[0] =Vec2(100,100);
point[1] =Vec2(100,200);
point[2] =Vec2(200,200);
point[3] =Vec2(200,100);
drawNode->
drawPolygon
(point,
4
,
Color4F
::
BLUE
,
5
,
Color4F
::
RED
);
drawNode->drawLine(Point(100,220),Point(300,Color4F::GRAY);
this->addChild(drawNode);
drawNode.drawCardinalSpline(config,tension,segments,lineWidth,color) //曲线 参数说明: //congfig:点数组 //tension:张力 //segments:段落 //lineWidth:线条宽度 //color:颜色 drawNode.drawCatmullRom(points,color) //同上 drawNode.drawCircle(center,radius,angle,drawLineToCenter,color) //画圆 //参数说明: 原点,半径,弧度,分段(越大越接近圆),原点到弧度的线(boolean),线条宽度,颜色 drawNode.drawCubicBezier(origin,control1,control2,destination,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)); drawNode.drawQuadBezier(origin,control,color) //画二次贝塞尔曲线 参考三次贝塞尔曲线 drawNode.drawDot(pos,color) //画点 // drawNode.drawDot(cc.p(60,20,cc.color(0.5,0.6,1)); drawNode.drawDots(points,color) //画点 points 点数组 drawNode.drawPoly(verts,fillColor,color) //画多边形 drawNode.drawRect(origin,lineColor) //画矩形 drawNode.drawSegment(from,to,color) //画线段 原文链接:https://www.f2er.com/cocos2dx/341677.html