美文网首页
cocos creator 转盘抽奖

cocos creator 转盘抽奖

作者: cmd_ts | 来源:发表于2018-11-07 22:12 被阅读154次

    代码下载:https://download.csdn.net/download/wolfdong7/10771392

    xxx.png
    const {ccclass, property} = cc._decorator;
    
    @ccclass
    export default class NewClass extends cc.Component {
    
        clickTimes = 6; //设置转盘指针多时间
        rounds = 10;    //设置转盘指针多少圈
        prize_per = 8;  //平均有几个奖品   X = [(360/8-10)]+(360/8)*(i-1) 
        // LIFE-CYCLE CALLBACKS:
    
        // onLoad () {}
    
        btn_start(){
            console.log('start');
            this.node.getChildByName('btn').active = false;
            var i = Math.floor(Math.random()*8)+1;
            console.log(i)
            var x = Math.random()*(360/8-10) +5 + (360/8)*(i-1);
            console.log(x);
            
            var rotation = cc.rotateTo(3,x + 360*3).easing(cc.easeSineInOut());
            var finished = cc.callFunc(() => {
                this.node.getChildByName('btn').active = true;
            }, this);
            var myAction = cc.sequence(rotation, finished);
            this.node.getChildByName('arrow').runAction(myAction);
        }
    
        start () {
    
        }
    
        // update (dt) {}
    }
    

    相关文章

      网友评论

          本文标题:cocos creator 转盘抽奖

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