关闭

CCClipingNode的使用

227人阅读 评论(0) 收藏 举报
分类:
var clipNode = new cc.ClippingNode();
        clipNode.setInverted(true);
        clipNode.setAlphaThreshold(0);//不设置此值则是图片的大小
        this.addChild(clipNode);

        var blackLayer = new cc.LayerColor(cc.color(0,0,0,0));
        blackLayer.setContentSize(cc.winSize.width,cc.winSize.height);
        blackLayer.runAction(cc.fadeTo(0.2,220));
        clipNode.addChild(blackLayer);

        var stencilNode = new cc.Node();
        //var stencil = new cc.DrawNode();
        //var valueW = 100;
        //var valueH = 100;
        //var rectangle = [cc.p(0, 0),cc.p(valueW, 0),
        //    cc.p(valueW, valueH),
        //    cc.p(0, valueH)];
        //
        //var white = cc.color(255, 255, 255, 255);
        //stencil.drawPoly(rectangle, white, 1, white);
        //stencil.setPosition(cc.pAdd(uiManager.mainLayer.getLayer(layerId.game_main).getItemPos(prop_type),cc.p(-valueW/2,-valueH/2)));
        //stencilNode.addChild(stencil);

        var proppos = cc.pAdd(uiManager.mainLayer.getLayer(layerId.game_main).getItemPos(prop_type),cc.p(0,3));

        var spt=new cc.Sprite("dj.png");//模板图片
        spt.setPosition(proppos);
        stencilNode.addChild(spt);

        clipNode.setStencil(stencilNode); //设置模板Stencil
        clipNode.setVisible(true);
        clipNode.setInverted(true);

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:28100次
    • 积分:1102
    • 等级:
    • 排名:千里之外
    • 原创:85篇
    • 转载:6篇
    • 译文:0篇
    • 评论:0条