vardraw=newcc.DrawNode();//创建drawnode对象
this.addChild(draw,10);
varcenterPos=cc.p(winSize.width/2,winSize.height/2);
//drawSegment---绘制直线
//用法:draw.drawSegment(from,to,lineWidth,color)
//参数
//from:起始点
//to:终点
//lineWidth:线条宽度
//color:线条颜色
draw.drawSegment(cc.p(0,0),cc.p(winSize.width,winSize.height),1,cc.color(255,255,255));
draw.drawSegment(cc.p(0,5,255));
//drawDot---绘制圆点
//draw.drawDot(pos,radius,color)
//draw.drawDots(points,color)//画点points点数组
draw.drawDot(cc.p(winSize.width/2,winSize.height/2),40,cc.color(0,128));
varpoints=[cc.p(60,60),cc.p(70,70),cc.p(60,60)];
draw.drawDots(points,4,255));
//drawCircle---绘制圆形
//draw.drawCircle(center,angle,segments,drawLineToCenter,color)
draw.drawCircle(cc.p(winSize.width/2,100,10,false,7,255));
draw.drawCircle(cc.p(winSize.width/2,50,cc.degreesToRadians(90),true,2,255));
//drawpoly---绘制多边形
//draw.drawPoly(verts,fillColor,color)
//notfill
varvertices=[cc.p(0,cc.p(50,50),cc.p(100,100),100)];
draw.drawPoly(vertices,null,255));
varvertices2=[cc.p(30,130),cc.p(30,230),200)];
draw.drawPoly(vertices2,255));
//fill
varvertices3=[cc.p(60,cc.p(80,200)];
draw.drawPoly(vertices3,255));
//drawrect---绘制矩形
//draw.drawRect(origin,destination,lineColor)
//notfill
draw.drawRect(cc.p(120,120),cc.p(200,200),255));
//fill
draw.drawRect(cc.p(120,220),300),180),cc.color(128,128,255));
//drawquadbezierpath---绘制二次贝塞尔曲线
//draw.drawQuadBezier(origin,control,color)
draw.drawQuadBezier(cc.p(0,cc.p(centerPos.x,centerPos.y),255));
//drawcubicbezierpath---绘制三次贝塞尔曲线
//draw.drawCubicBezier(origin,control1,control2,color)
draw.drawCubicBezier(cc.p(winSize.width/2,cc.p(winSize.width/2+30,winSize.height/2+50),cc.p(winSize.width/2+60,winSize.height/2-50),255));
//drawcardinalspline---绘制曲线
//drawNode.drawCardinalSpline(config,tension,color)
varvertices4=[
cc.p(centerPos.x-130,centerPos.y-130),cc.p(centerPos.x-130,centerPos.y+130),cc.p(centerPos.x+130,centerPos.y-130)
];
draw.drawCardinalSpline(vertices4,0.5,255));
原文链接:https://www.f2er.com/cocos2dx/340308.html