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
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內(nèi)容

  • 兩個人在一起多久并不重要,年齡的差異也不重要,重要的是你有沒有在這個人心里,有些人哪怕在一起一天,卻在心里待了一輩...
    太陽是唯一閱讀 163評論 1 2
  • 剛下過雨,地里也剛澆過水,到處都是濕滑的,順著田埂,母親在前,我在后面。 旁邊的水溝里還有水流著,剛剛淹沒過溝...
    anling閱讀 333評論 0 0
  • 初識簡書 近幾日,看到幾位大神寫了自己與簡書之間的故事,想來,我與簡書之間的緣分也真的是不淺呢。 ...
    子窈閱讀 302評論 7 4

友情鏈接更多精彩內(nèi)容