import { Label } from 'cc'; import { _decorator, Component, Node } from 'cc'; import PlayerData from '../../../data/PlayerData'; import GBattleData, { GBattleDataEnum } from '../../../data/GBattleData'; import { app } from '../../../App'; import { tween } from 'cc'; const { ccclass, property } = _decorator; @ccclass('MainPlayerInfo') export class MainPlayerInfo extends Component { //玩家名称 @property(Label) playerNameLabel:Label; //玩家战力 @property(Label) playerFC:Label; _FC:number = 0; get FC(){ return this._FC } set FC(value:number){ this._FC = value; this.playerFC.string = `${Math.floor(value)}`; } protected onLoad(): void { this.onUpdateView(); app.event.on(GBattleDataEnum.UPDARE_ATTRIBUTE_SUCCESS,this.onUpdateView,this); } protected onDestroy(): void { app.event.off(GBattleDataEnum.UPDARE_ATTRIBUTE_SUCCESS,this.onUpdateView,this); } onUpdateView() { this.playerNameLabel.string = `${PlayerData.getIns().getInfo().playerName}`; //过度 tween(this.getComponent(MainPlayerInfo)) .to(.5,{FC:GBattleData.getIns().data.getAllFC()}) .start(); } }