感谢烂莴笋叶子提交的修复LabelChange组件变化的数字为整形时,往上取整后变回原值的问题

This commit is contained in:
dgflash
2023-08-11 10:06:15 +08:00
parent 0047c5433e
commit 2f434655c7
2 changed files with 22 additions and 20 deletions

View File

@@ -2,7 +2,7 @@
* @Author: dgflash
* @Date: 2022-04-14 17:08:01
* @LastEditors: dgflash
* @LastEditTime: 2022-04-14 18:26:24
* @LastEditTime: 2023-08-11 10:00:51
*/
import { _decorator } from "cc";
import LabelNumber from "./LabelNumber";
@@ -88,7 +88,16 @@ export class LabelChange extends LabelNumber {
return;
}
let num = this.num + dt * this.speed;
if (this.isInteger) num = Math.ceil(num);
if (this.isInteger){
if(this.end < this.num)
{
num = Math.floor(num);
}
else{
num = Math.ceil(num);
}
}
/** 变化完成 */
if (this.isEnd(num)) {

View File

@@ -2,7 +2,7 @@
* @Author: dgflash
* @Date: 2022-04-14 17:08:01
* @LastEditors: dgflash
* @LastEditTime: 2022-04-14 18:23:46
* @LastEditTime: 2023-08-11 09:54:30
*/
import { error, Label, _decorator } from "cc";
@@ -14,37 +14,30 @@ const { ccclass, property, menu } = _decorator;
export default class LabelNumber extends Label {
@property
_num: number = 0;
@property
set num(value: number) {
this._num = value;
this.updateLabel();
}
get num(): number {
return this._num;
}
@property({
tooltip: "是否显示货币符号"
})
_showSym: string = "";
@property
public set num(value: number) {
this._num = value;
this.updateLabel();
}
public get num(): number {
return this._num;
}
@property
public set showSym(value: string) {
set showSym(value: string) {
if (value) {
this._showSym = value;
this.updateLabel();
}
}
public get showSym(): string {
get showSym(): string {
return this._showSym;
}
@property
useFix: boolean = true;
/** 刷新lab */
protected updateLabel() {
if (typeof (this._num) != "number") {