12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- import FSprite from "./FSprite";
- /**
- * 面板数据显示
- */
- const {ccclass, property} = cc._decorator;
- @ccclass
- export default class FPanel extends cc.Component {
- @property(cc.ProgressBar)
- mHPBar: cc.ProgressBar = null;
- @property(cc.Label)
- mLabel: cc.Label = null;
-
- public sprite:FSprite;
- onLoad () {
- this.sprite = this.node.parent.getComponent(FSprite);
- if(this.mLabel){
- this.mLabel.string = '';
- }
- }
- /**
- * 更新当前面板
- */
- public updatePanel(){
- if(this.sprite){
- this.mHPBar.progress = this.sprite.hp/this.sprite.attrData.hp;
- if(this.mLabel){
- this.mLabel.string = this.sprite.hp+'/'+this.sprite.attrData.hp;
- }
- if(this.sprite.hp <= 0){
- this.node.active = false;
- }else{
- this.node.active = true;
- }
- }
- }
- public setCancel(){
- if(this.sprite &&this.sprite.isValid &&this.sprite.attrData.type != 2){
- this.node.stopAllActions();
- cc.tween(this.node).sequence(
- cc.delayTime(2),
- cc.callFunc(()=>{
- this.node.active = false;
- })
- ).start();
- }
- }
- public setClose(){
- this.node.active = false;
- }
- }
|