1、引言
这里分享一个刮刮卡效果,闲言少叙,我们直接上代码。
2、场景搭建
场景搭建如图所示:
3、代码部分
详细代码如下所示:
const {ccclass, property} = cc._decorator;
@ccclass
export default class test extends cc.Component {
// LIFE-CYCLE CALLBACKS:
mask = null;
onLoad () {
this.mask = this.node.getChildByName('mask').getComponent(cc.Mask);
this.node.on(cc.Node.EventType.TOUCH_START,function (e){
console.log('touch start');
this.commonFunc(e)
},this);
this.node.on(cc.Node.EventType.TOUCH_MOVE,(e)=>{
console.log('touch move');
this.commonFunc(e)
},this);
}
sta