美文网首页
cocos creator 刮刮乐

cocos creator 刮刮乐

作者: cmd_ts | 来源:发表于2018-10-19 20:28 被阅读326次

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

相关文章

  • cocos creator 刮刮乐

    https://gitee.com/wolfdong7/guaguale

  • 刮刮乐

  • 刮刮乐

    2007年3月3日,特别的日子。 为啥特别? 第一次坐飞机,青岛飞西安,提前4个小时就到机场了,在网上研究过攻略,...

  • 刮刮乐

    2014年11月3日 刮刮乐 今天杏子又在济南火车站候车了,这次她是故地重游,明显轻松了许多。 ...

  • 刮刮乐

    设置刮开后,显示的文字Label UILabel *label = [[UILabel alloc]initWit...

  • 刮刮乐

    刮刮乐这个东西真的是越刮越快乐,尤其是他给我准备的30张,现在有些喜欢30这个数字了,哈哈哈哈哈! 他给我准备...

  • 刮刮乐

    最近幻想中奖挣大钱的两个人于今晚走进彩票店刮起了刮刮乐,五块钱一张,最后刮了六张,付了十块钱,而我依然是好运绝缘体...

  • 刮刮乐热潮

    近日中国福利彩票在县城体育馆做一个瓜瓜乐的活动,大体内容就是五块钱一张的刮刮乐有机会赢取三十万大奖。而更吸引人的是...

  • 刮刮乐效果

    实现原理: 利用layer的mask遮罩 + 贝塞尔曲线UIBezierPath 关键代码: 效果图:

  • canvas— —刮刮乐

    今天,结合上一篇文章的抽奖小游戏,用canvas来写一个小游戏——刮刮乐。首先,用canvas做一个画布,宽高各为...

网友评论

      本文标题:cocos creator 刮刮乐

      本文链接:https://www.haomeiwen.com/subject/ywvuzftx.html