Parcourir la source

Merge branch 'master' of http://git.mokasz.com/zouyong/mk_framework

kaka il y a 5 ans
Parent
commit
cee84267c9

+ 8 - 7
assets/script/game/component/NumberAnim.ts

@@ -22,7 +22,7 @@ export default class NumberAnim extends cc.Component {
         this.toFixed = toFixed;
         this.len_target = new_value.toString().length;
         this.targetProgress = new_value;
-        this.PlayMoneyAni(0.3)
+        this.PlayMoneyAni(0.3);
     }
 
     //////////////////////////////////数字滚动效果//////////////////////////////////
@@ -43,12 +43,11 @@ export default class NumberAnim extends cc.Component {
     /** 保留小数点位数 */
     private toFixed: number = 0;
 
-    private PlayMoneyAni(time) {
+    private PlayMoneyAni(time: number) {
         this.totalTime = time;
-        this.delta = (this.targetProgress - this.lastNum) / time;
+        this.delta = (this.targetProgress - this.lastNum);// / time;
         this.curValue = this.lastNum;
         this.curTime = 0;
-        // console.log("--->Update Time: " + time + " delta: " + this.delta + " curValue: " + this.curValue + " lastNum: " + this.lastNum);
         this.isPlayAni = true;
     }
 
@@ -62,18 +61,20 @@ export default class NumberAnim extends cc.Component {
                     this.curValue = this.targetProgress;
                     this.lastNum = this.targetProgress;
                 }
-                // console.log("-->CurValue:" + this.curValue);
             } else {
                 this.isPlayAni = false;
                 this.curTime = this.totalTime;
-                //this.unschedule(this.UpdateAni);
                 this.curValue = this.targetProgress;
                 this.lastNum = this.targetProgress;
             }
             if (this.curValue == this.targetProgress) {
                 this.lbl_count.string = `${this.targetProgress}`;
             } else {
-                this.lbl_count.string = `${this.curValue.toFixed(this.toFixed)}`;
+                if (!this.curValue) {
+                    mk.console.log('数字动画出现异常:', this.curValue);
+                    this.curValue = this.targetProgress;
+                }
+                this.lbl_count.string = this.curValue.toFixed(this.toFixed);
             }
         }
     }

+ 1 - 1
assets/script/game/game/Game.ts

@@ -136,7 +136,7 @@ export default class Game extends cc.Component {
         // this.lbl_rmb.node.getComponent('NumberAnim').setValue(gData.gameData.gameData.piggyBank);
 
         const new_count = gData.gameData.gameData.piggyBank / 100;
-        if (parseInt(this.lbl_rmb.string) != 0 && new_count != 0) {
+        if (parseInt(this.lbl_rmb.string) == 0 && new_count != 0 || parseInt(this.lbl_rmb.string) != 0 && new_count == 0) {
             if (this.lbl_rmb.string != new_count.toFixed(2)) {
                 this.lbl_rmb.node.getComponent(NumberAnim).setValue(parseFloat(new_count.toFixed(2)), 2);
             }