标签:rect idt 示例 style cocos2d-x his app 坐标 attach
1 //图层定位,以屏幕中心偏移 2 var offsetX = 0; 3 var offsetY = 0; 4 //图层大小 5 var clipWidth = 600; 6 var clipHeight =400; 7 //圆角半径 8 var radius =25; 9 //圆角层实现代码 10 var size = cc.winSize; 11 var stencil = new cc.DrawNode(); 12 stencil.drawRect(cc.p((size.width-clipWidth)/2+offsetX,(size.height-clipHeight)/2+offsetY+radius),cc.p(size.width/2+clipWidth/2+offsetX,size.height/2+clipHeight/2+offsetY-radius),cc.color(0,0,0),1,cc.color(0,0,0)); 13 stencil.drawRect(cc.p((size.width-clipWidth)/2+offsetX+radius,(size.height-clipHeight)/2+offsetY),cc.p(size.width/2+clipWidth/2+offsetX-radius,size.height/2+clipHeight/2+offsetY),cc.color(0,0,0),1,cc.color(0,0,0)); 14 stencil.drawCircle(cc.p(size.width/2-clipWidth/2+offsetX+radius,size.height/2-clipHeight/2+offsetY+radius),radius/3,0,100,false,radius,cc.color(0,0,0)); 15 stencil.drawCircle(cc.p(size.width/2+clipWidth/2+offsetX-radius,size.height/2-clipHeight/2+offsetY+radius),radius/3,0,100,false,radius,cc.color(0,0,0)); 16 stencil.drawCircle(cc.p(size.width/2+clipWidth/2+offsetX-radius,size.height/2+clipHeight/2+offsetY-radius),radius/3,0,100,false,radius,cc.color(0,0,0)); 17 stencil.drawCircle(cc.p(size.width/2-clipWidth/2+offsetX+radius,size.height/2+clipHeight/2+offsetY-radius),radius/3,0,100,false,radius,cc.color(0,0,0)); 18 var clippingPanel = new cc.ClippingNode(); 19 clippingPanel.stencil = stencil; 20 //层颜色 21 var layer = new cc.LayerColor(cc.color(255,0,0),clipWidth,clipHeight); 22 layer.x = (size.width-clipWidth)/2+offsetX; 23 layer.y = (size.height-clipHeight)/2+offsetY; 24 //层透明度 25 layer.opacity = 200; 26 clippingPanel.addChild(layer); 27 this.addChild(clippingPanel);
标签:rect idt 示例 style cocos2d-x his app 坐标 attach
原文地址:http://www.cnblogs.com/luorende/p/6794953.html