觉醒时刻
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
juexingshike/assets/Scripts/SCommon/properNaoLi.ts

54 lines
1.7 KiB

import EventMgr from "../../FrameWork/Event/EventMgr";
import { ryw_Event } from "../../FrameWork/Event/EventEnum";
import Common5 from "../../Platform/th/Common5";
import User from "../../FrameWork/User/User";
const { ccclass, property } = cc._decorator;
@ccclass
export default class properNaoLi extends cc.Component {
onLoad() {
this.showProperty();
EventMgr.onEvent_custom(ryw_Event.updateProperty, (value, type) => {
this.showProperty();
if (value == 0 && type != 2) {
return
}
if (isNaN(value)) {
} else {
let changeLabel_1 = this.node.getChildByName('脑力').getChildByName('changeLabel')
this.changeLabelAni(changeLabel_1, value)
}
}, this);
}
start() { }
showProperty() {
let numStr_1 = this.node.getChildByName('脑力').getChildByName('numStr');
let naoli = Common5.getNumberChangeHanzi(User.getProper_NaoLi(), '2') as string;
numStr_1.getComponent(cc.Label).string = naoli;
}
changeLabelAni(labelNode, num) {
let label = cc.instantiate(labelNode)
label.active = true
label.parent = labelNode.parent
if (num > 0) {
label.getComponent(cc.Label).string = "+" + Common5.getNumberChangeHanzi(num, '1', 1)
} else if (num < 0) {
label.getComponent(cc.Label).string = Common5.getNumberChangeHanzi(num, '1', 1) + ''
}
cc.tween(label)
.delay(0.2)
.by(2, { y: 20, opacity: 0 })
.call(() => {
label.removeFromParent()
})
.start()
}
}