https://gitee.com/wolfdong7/guaguale
const {ccclass, property} = cc._decorator;
@ccclass
export default class NewClass extends cc.Component {
// LIFE-CYCLE CALLBACKS:
mask:any = 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);
}
start () {
}
commonFunc (event){
var point = event.touch.getLocation();
point = this.node.convertToNodeSpaceAR(point);
this._addCircle(point);
}
_addCircle(point) {
var graphics = this.mask._graphics;
console.log("xxxx:",graphics)
var color = cc.color(0, 0, 0, 255);
graphics.rect(point.x,point.y,50,30)
graphics.lineWidth = 2
graphics.fillColor = color
//graphics.strokeColor = color
graphics.fill()
}
// update (dt) {}
}
1539951863361.gif