| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- import TurnableItem from "./TurnableItem";
- const { ccclass, property } = cc._decorator;
- @ccclass
- export default class Turnable extends cc.Component {
- @property(cc.Node)
- node_turn: cc.Node = null;
- @property(cc.Node)
- node_items: cc.Node[] = [];
- @property(cc.Node)
- btn_draw: cc.Node = null;
- @property(cc.Sprite)
- btn_close: cc.Sprite = null;
- @property(cc.RichText)
- lbl_left: cc.RichText = null;
- private isPlaying: boolean = false;
- onLoad() {
- }
- /**
- * 初始化奖励和抽奖次数
- */
- private initData() {
- for (let i = 0; i < this.node_items.length; i++) {
- let sc = this.node_items[i].getComponent(TurnableItem);
- sc.initData(i + "");
- }
- this.updateLeftTimes();
- }
- clickDraw() {
- if (gData.turnable.leftTimes > 0 && !this.isPlaying) {
- this.draw();
- }
- }
- private draw() {
- gData.turnable.leftTimes--;
- this.node_turn.rotation = 1800;
- let index = 2;
- let tar = index * 60;
- cc.tween(this.node_turn)
- .to(3, { rotation: tar }, { easing: 'expoInOut' })
- .call(() => {
- this.updateLeftTimes();
- }, this).start();
- }
- updateLeftTimes(){
- this.lbl_left.string = `剩余:<color=#FFED99>${gData.turnable.leftTimes}</color>次`;
- }
- update() {
- if (!gData.turnable.dataFinish) {
- gData.turnable.init();
- }
- else{
- this.initData();
- }
- }
- }
|