觉醒时刻
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.
 
 
 

63 lines
2.0 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";
import PrefabManage, { GameType } from "../PrefabManager/PrefabManage";
import TiShengShouYi from "../GameMethodRes/TiShengShouYi/TiShengShouYi";
const { ccclass, property } = cc._decorator;
@ccclass
export default class properTiLi extends cc.Component {
onLoad() {
this.showProperty();
EventMgr.onEvent_custom(ryw_Event.updateProperty, (value, type) => {
this.showProperty();
if (value == 0 && type != 1) {
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 tili = Common5.getNumberChangeHanzi(User.getProper_TiLi(), '2') as string;
numStr_1.getComponent(cc.Label).string = tili;
}
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();
}
// 点击查看体力
onClick() {
PrefabManage.loadPrefabByType(GameType.TiShengShouYi, null, (prefabNode) => {
prefabNode.getComponent(TiShengShouYi).initView(0);
})
}
}