金币数字滚动增加

金币数字滚动增加

  //刷新金币
    updateMoney(num) {
        if (this.updateMoneyAnimState == AnimState.isPlaying) {
            config.moneyCount += num;
            this.moneyLabel.string = config.moneyCount;
            return;
        };
        let timeCount = 10;
        let money = config.moneyCount;
        let callback = () => {
            this.updateMoneyAnimState = AnimState.isPlaying;
            timeCount--;
            let Pnum = parseInt(num / timeCount)
            this.moneyLabel.string = money + Pnum;
            if (timeCount <= 0) {
                this.updateMoneyAnimState = AnimState.finished;
                config.moneyCount += num;
                if (config.moneyCount <= 0) {
                    config.moneyCount = 0;
                };
                this.moneyLabel.string = config.moneyCount;
                this.unschedule(callback);
                return;
            }
        };
        this.schedule(callback, 0.03);
    },

你可能感兴趣的:(小技巧)