cocos2dx-js cc.DrawNode
来源:互联网 发布:爱的算法txt下载 编辑:程序博客网 时间:2024/05/16 05:36
var draw = new cc.DrawNode(); //创建drawnode对象
this.addChild(draw, 10);
var centerPos = 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, 0, 255, 255));
draw.drawSegment(cc.p(0, winSize.height), cc.p(winSize.width, 0), 5, cc.color(255, 0, 0, 255));
//drawDot --- 绘制圆点
//draw.drawDot(pos, radius, color)
//draw.drawDots(points, radius, color) //画点 points 点数组
draw.drawDot(cc.p(winSize.width / 2, winSize.height / 2), 40, cc.color(0, 0, 255, 128));
var points = [cc.p(60, 60), cc.p(70, 70), cc.p(60, 70), cc.p(70, 60)];
draw.drawDots(points, 4, cc.color(0, 255, 255, 255));
//drawCircle --- 绘制圆形
//draw.drawCircle(center, radius, angle, segments, drawLineToCenter, lineWidth, color)
draw.drawCircle(cc.p(winSize.width / 2, winSize.height / 2), 100, 0, 10, false, 7, cc.color(0, 255, 0, 255));
draw.drawCircle(cc.p(winSize.width / 2, winSize.height / 2), 50, cc.degreesToRadians(90), 100, true, 2, cc.color(0, 255, 255, 255));
//draw poly --- 绘制多边形
//draw.drawPoly(verts, fillColor, lineWidth, color)
//not fill
var vertices = [cc.p(0, 0), cc.p(50, 50), cc.p(100, 50), cc.p(100, 100), cc.p(50, 100) ];
draw.drawPoly(vertices, null, 5, cc.color(255, 255, 0, 255));
var vertices2 = [cc.p(30, 130), cc.p(30, 230), cc.p(50, 200)];
draw.drawPoly(vertices2, null, 2, cc.color(255, 0, 255, 255));
//fill
var vertices3 = [cc.p(60, 130), cc.p(60, 230), cc.p(80, 200)];
draw.drawPoly(vertices3, cc.color(0, 255, 255, 50), 2, cc.color(255, 0, 255, 255));
//draw rect --- 绘制矩形
//draw.drawRect(origin, destination, fillColor, lineWidth, lineColor)
//not fill
draw.drawRect(cc.p(120, 120), cc.p(200, 200), null, 2, cc.color(255, 0, 255, 255));
//fill
draw.drawRect(cc.p(120, 220), cc.p(200, 300), cc.color(0, 255, 255, 180), 2, cc.color(128, 128, 0, 255));
// draw quad bezier path --- 绘制二次贝塞尔曲线
// draw.drawQuadBezier(origin, control, destination, segments, lineWidth, color)
draw.drawQuadBezier(cc.p(0, winSize.height), cc.p(centerPos.x, centerPos.y), cc.p(winSize.width, winSize.height), 50, 2, cc.color(255, 0, 255, 255));
// draw cubic bezier path --- 绘制三次贝塞尔曲线
// draw.drawCubicBezier(origin, control1, control2, destination, segments, lineWidth, color)
draw.drawCubicBezier(cc.p(winSize.width / 2, winSize.height / 2), cc.p(winSize.width / 2 + 30, winSize.height / 2 + 50),
cc.p(winSize.width / 2 + 60, winSize.height / 2 - 50), cc.p(winSize.width, winSize.height / 2), 100, 2, cc.color(255, 0, 255, 255));
// draw cardinal spline --- 绘制曲线
// drawNode.drawCardinalSpline(config, tension, segments, lineWidth, color)
var vertices4 = [
cc.p(centerPos.x - 130, centerPos.y - 130),
cc.p(centerPos.x - 130, centerPos.y + 130),
cc.p(centerPos.x + 130, centerPos.y + 130),
cc.p(centerPos.x + 130, centerPos.y - 130),
cc.p(centerPos.x - 130, centerPos.y - 130)
];
this.addChild(draw, 10);
var centerPos = 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, 0, 255, 255));
draw.drawSegment(cc.p(0, winSize.height), cc.p(winSize.width, 0), 5, cc.color(255, 0, 0, 255));
//drawDot --- 绘制圆点
//draw.drawDot(pos, radius, color)
//draw.drawDots(points, radius, color) //画点 points 点数组
draw.drawDot(cc.p(winSize.width / 2, winSize.height / 2), 40, cc.color(0, 0, 255, 128));
var points = [cc.p(60, 60), cc.p(70, 70), cc.p(60, 70), cc.p(70, 60)];
draw.drawDots(points, 4, cc.color(0, 255, 255, 255));
//drawCircle --- 绘制圆形
//draw.drawCircle(center, radius, angle, segments, drawLineToCenter, lineWidth, color)
draw.drawCircle(cc.p(winSize.width / 2, winSize.height / 2), 100, 0, 10, false, 7, cc.color(0, 255, 0, 255));
draw.drawCircle(cc.p(winSize.width / 2, winSize.height / 2), 50, cc.degreesToRadians(90), 100, true, 2, cc.color(0, 255, 255, 255));
//draw poly --- 绘制多边形
//draw.drawPoly(verts, fillColor, lineWidth, color)
//not fill
var vertices = [cc.p(0, 0), cc.p(50, 50), cc.p(100, 50), cc.p(100, 100), cc.p(50, 100) ];
draw.drawPoly(vertices, null, 5, cc.color(255, 255, 0, 255));
var vertices2 = [cc.p(30, 130), cc.p(30, 230), cc.p(50, 200)];
draw.drawPoly(vertices2, null, 2, cc.color(255, 0, 255, 255));
//fill
var vertices3 = [cc.p(60, 130), cc.p(60, 230), cc.p(80, 200)];
draw.drawPoly(vertices3, cc.color(0, 255, 255, 50), 2, cc.color(255, 0, 255, 255));
//draw rect --- 绘制矩形
//draw.drawRect(origin, destination, fillColor, lineWidth, lineColor)
//not fill
draw.drawRect(cc.p(120, 120), cc.p(200, 200), null, 2, cc.color(255, 0, 255, 255));
//fill
draw.drawRect(cc.p(120, 220), cc.p(200, 300), cc.color(0, 255, 255, 180), 2, cc.color(128, 128, 0, 255));
// draw quad bezier path --- 绘制二次贝塞尔曲线
// draw.drawQuadBezier(origin, control, destination, segments, lineWidth, color)
draw.drawQuadBezier(cc.p(0, winSize.height), cc.p(centerPos.x, centerPos.y), cc.p(winSize.width, winSize.height), 50, 2, cc.color(255, 0, 255, 255));
// draw cubic bezier path --- 绘制三次贝塞尔曲线
// draw.drawCubicBezier(origin, control1, control2, destination, segments, lineWidth, color)
draw.drawCubicBezier(cc.p(winSize.width / 2, winSize.height / 2), cc.p(winSize.width / 2 + 30, winSize.height / 2 + 50),
cc.p(winSize.width / 2 + 60, winSize.height / 2 - 50), cc.p(winSize.width, winSize.height / 2), 100, 2, cc.color(255, 0, 255, 255));
// draw cardinal spline --- 绘制曲线
// drawNode.drawCardinalSpline(config, tension, segments, lineWidth, color)
var vertices4 = [
cc.p(centerPos.x - 130, centerPos.y - 130),
cc.p(centerPos.x - 130, centerPos.y + 130),
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, 100, 2, cc.color(255, 255, 255, 255));
0 0
- cocos2dx-js cc.DrawNode
- cc.DrawNode
- cocos2d-js cc.DrawNode画图参考大全
- cocos2d-js cc.DrawNode用法示例
- cocos2d-js cc.DrawNode用法示例
- [转]cocos2d-js cc.DrawNode画图参考大全
- Cocos2dx-js cc.Class的实例化
- cocos2dx-3.2(34) DrawNode 绘图API
- cocos2dx给DrawNode的shader传递Texture2D
- cocos2dx DrawNode和ClippingRectangleNode 使用详解
- DrawNode
- quick-cocos2dx 中的cc({})
- cocos2dx cc.SpriteBatchNode运用
- cocos2dx[3.2](17)——简单绘图DrawNode
- cocos2dx中DrawNode画线锯齿和非凸多边形填充
- cocos2dx DrawNode.drawSegment绘制出来的线粗细不一
- cc笔记:cocos2dx 常见动作
- Cocos2d-js 学习(四): DrawNode简单使用
- APP中常见上下循环滚动通知的简单实现,点击可进入详情
- 【获取iOS设备类型与系统版本号】结构体utsname与uname方法的使用
- 给未签名的空包签名
- 进制,内存分析
- uva 10652 凸包 + 更新版计算几何模板
- cocos2dx-js cc.DrawNode
- leetcode 27 Remove Element
- linux硬盘分区和挂载命令《二》
- NSNotificationCenter --- 消息机制
- 持续更新--写shellcode常用网站
- Flex之旅--Flex4容器和布局定位
- 简单工厂模式
- WPF-自定义滚动条ScrollBar
- C/C++--memcpy函数实现