cocos2d-x简单绘图(DrawNode)
2015-08-22 11:40
585 查看
DrawNode简单绘图示例如下:
DrawNode* drawNode=DrawNode::create();
//绘制空心4边形和直线
Vec2 point[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,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)
//画线段
DrawNode* drawNode=DrawNode::create();
//绘制空心4边形和直线
Vec2 point[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,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-js 2048带动画实现
- 【cocos2d-x】3.0使用cocos-console创建,编,部署游戏
- cocos2dx 3.7中 AppDelegate.h的class TestController;这种写法的具体意思不太明白,只能猜是类似于外部定义的东西。
- 初识Cocos2D-X
- android cocos2dx游戏-加入截图和分享微博功能
- 五、触摸事件的吞噬和传递
- 第一篇 cocos2d-x学习总结
- 2.cocos2dx 3.2在语法的差异,lambada使用表达式和function和bind使用功能
- 火云开发课堂 - 《使用Cocos2d-x 开发3D游戏》系列 第六节:VS基础:树木的摇动
- c++11特性与cocos2d-x 3.0之std::bind与std::function
- quick - cocos2d 本地数据存储
- c++11特性与cocos2d-x 3.0之std::bind与std::function
- cocos2dx 3.1.1移植安卓apk (lua交叉编译器项目 mac环境)
- cocos2d-js导弹跟踪算法(一边追着目标移动一边旋转角度)
- cocos2dx-3.1加入cocosStudio参考库 libCocosStudio
- cocos studio使用bmpfont生成的字体
- Cocos2d-x中,ActionInstant类的各个子类
- 记录之——cocos2d-x v3.0 发布说明
- 程序员如何提高工作效率(cocos2dx+lua+VS2013+BabeLua)
- cocos2d-x 播放 cocostudio导出的帧动画