cocos creator 转盘抽奖

代码下载: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) {}
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。