绘制点、线段和多边形的节点。 由于它使用了"批处理"(Batch draw),因此它绘制点、线段、多边形都要比“drawing primitives”快
auto spot0 = DrawNode::create();
this->addChild(spot0);
//画一个点,这个点位正方形的
spot0->drawPoint(Point(100,50),50,Color4F(100,236,121,1));
//画line,
auto line = DrawNode::create();
this->addChild(line);
line->drawLine(Point(100,100),Point(200,200,200));
line->setLineWidth(10);
//line->setColor(Color3B(255,255));//这里改变颜色没有作用
auto Rect = DrawNode::create();
this->addChild(Rect);
Rect->drawRect(Point(300,300),200),Color4F(255,255,100));
Rect->setColor(Color3B(100,200));
auto Poly = DrawNode::create();
this->addChild(Poly);
Vec2 point1[6];
point1[0] = Vec2(250,100);
point1[1] = Vec2(300,100);
point1[2] = Vec2(325,125);
point1[3] = Vec2(300,150);
point1[4] = Vec2(250,150);
point1[5] = Vec2(225,125);
Poly->drawPoly(point1,6,true,100));
//这里的第四个参数是好多点,360个可以刚刚好画一个圆 Poly->drawCircle(Point(100,30,360,false,100)); //这里的第5,6个参数是缩放圆的整体大小 Poly->drawCircle(Point(100,150),0.5f,100)); //这里的第4个参数越大,贝塞尔曲线越来越像弧线 Poly->drawQuadBezier(Vec2(150,Vec2(200,250),Vec2(300,2,100));
原文链接:https://www.f2er.com/cocos2dx/339486.html