加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

【cocos2dx-js 学习分享 七】游戏遮罩

发布时间:2020-12-14 19:52:19 所属栏目:百科 来源:网络整理
导读://创建游戏遮罩 this.clip=new cc.ClippingNode(); this.clip.setInverted(true); this.clip.setAlphaThreshold(0.0); this.addChild(this.clip,this.kTagClipNode ); var back=new cc.LayerColor(cc.color(0,200,0)); this.clip.addChild(back); var nodef=


//创建游戏遮罩
this.clip=new cc.ClippingNode();
this.clip.setInverted(true);
this.clip.setAlphaThreshold(0.0);
this.addChild(this.clip,this.kTagClipNode );

var back=new cc.LayerColor(cc.color(0,200,0));
this.clip.addChild(back);



var nodef=new cc.Node();
var close=new cc.Sprite(res.CloseNormal_png);
nodef.addChild(close);
nodef.setPosition(cc.p(size.width/2,size.height/2));
this.clip.setStencil(nodef);

this.tip = new cc.Sprite(res.tip_png);
this.tip.setScale(0.5);
this.tip.setRotation(60);
this.tip.setPosition(cc.p(size.width/2-70,size.height/2+50));
this.addChild( this.tip,this.kTagTip);

this.tip.runAction(cc.repeatForever( cc.sequence( cc.scaleBy(0.25,0.95),cc.scaleTo(0.25,0.5) ) ));

//触摸开始 onTouchBegan:function (touch,event) { var _size =cc.director.getWinSize(); var point=touch.getLocation(); var rect=cc.rect(_size.width/2-30,_size.height/2-30,60,60); if (cc.rectContainsPoint(rect,point)) { //this.removeChild(this.tip,true); var asd = cc.director.getRunningScene().getChildByTag(1000); asd.removeChild(asd.tip); asd.removeChild(asd.clip); return true; } return false; },

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读