cocos creator 刮刮乐

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
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 两个人在一起多久并不重要,年龄的差异也不重要,重要的是你有没有在这个人心里,有些人哪怕在一起一天,却在心里待了一辈...
    太阳是唯一阅读 1,279评论 1 2
  • 刚下过雨,地里也刚浇过水,到处都是湿滑的,顺着田埂,母亲在前,我在后面。 旁边的水沟里还有水流着,刚刚淹没过沟...
    anling阅读 2,383评论 0 0
  • 初识简书 近几日,看到几位大神写了自己与简书之间的故事,想来,我与简书之间的缘分也真的是不浅呢。 ...
    子窈阅读 1,832评论 7 4

友情链接更多精彩内容