代码下载:https://download.csdn.net/download/wolfdong7/10771392
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) {}
}
网友评论