寒風的Cocos之旅之C++篇---drawNode用法

前端之家收集整理的这篇文章主要介绍了寒風的Cocos之旅之C++篇---drawNode用法前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
auto s = Director::getInstance()->getWinSize();

auto draw = DrawNode::create();

addChild(draw,10);

// Draw 10 circles
//画同心圆
for( int i=0; i < 10; i++)
{
draw->drawDot(Point(s.width/2,s.height/2),10*(10-i),Color4F(CCRANDOM_0_1(),CCRANDOM_0_1(),1));
}
// Draw polygons
画大三角形
Point points[] = { Point(s.height/4,0),Point(s.width,s.height/5),Point(s.width/3*2,s.height) };
draw->drawPolygon(points,sizeof(points)/sizeof(points[0]),Color4F(1,0.5),4,Color4F(0,1,SimSun; font-size:16px; line-height:24px">// star poly (triggers buggs)
画多边形
const float o=80;
const float w=20;
const float h=50;
Point star[] = {
Point(o+w,o-h),Point(o+w*2,o),// lower spike
Point(o + w*2 + h,o+w ),Point(o + w*2,o+w*2),SimSun; font-size:16px; line-height:24px">// right spike
{o +w,o+w*2+h},{o,o+w*2},SimSun; font-size:16px; line-height:24px">// top spike
{o -h,o+w},o},SimSun; font-size:16px; line-height:24px">// left spike
};
draw->drawPolygon(star,sizeof(star)/sizeof(star[0]),0.0),SimSun; font-size:16px; line-height:24px">// star poly (doesn't trigger bug... order is important un tesselation is supported.
//画星
const float o=180;
Point(o,Point(o+w,SimSun; font-size:16px; line-height:24px">Point(o +w,o+w*2+h),Point(o,SimSun; font-size:16px; line-height:24px">Point(o -h,o+w),SimSun; font-size:16px; line-height:24px">// Draw segment
画直线,可加粗
draw->drawSegment(Point(20,s.height),Point(20,10,SimSun; font-size:16px; line-height:24px">draw->drawSegment(Point(10,Point(s.width/2,40,0.5));
// Draw triangle
画三角形
draw->drawTriangle(Point(10,10),Point(70,30),Point(100,140),SimSun; font-size:16px; line-height:24px">// Draw some beziers
画二次方程的贝塞尔曲线
draw->drawQuadraticBezier(Point(s.width - 150,s.height - 150),Point(s.width - 70,s.height - 10),Point(s.width - 10,SimSun; font-size:16px; line-height:24px">画三次方程的贝塞尔曲线
draw->drawCubicBezier(Point(s.width - 250,40),100),Point(s.width - 30,250),s.height - 50),0.5)); 原文链接:https://www.f2er.com/cocos2dx/341197.html

猜你在找的Cocos2d-x相关文章