cb/assets/Script/heathnum.ts
2025-07-02 16:41:42 +08:00

55 lines
1.4 KiB
TypeScript

import NumberToImage from "./NumberToImage";
import JiaZai from "./JiaZai";
const { ccclass, property } = cc._decorator;
@ccclass
export default class NewClass extends cc.Component {
//商店界面
@property(cc.Node)
heath: cc.Node = null;
//体力数量
@property(cc.Node)
coin: cc.Node = null;
//精灵数组
@property([cc.SpriteFrame])
spriteFrames: cc.SpriteFrame[] = [];
//切换的节点
@property(cc.Node)
switchNode: cc.Node = null;
start() {
this.openPop();
}
//打开商店界面
openPop() {
console.log("打开heath弹窗",cc.fx.GameConfig.GM_INFO.hp);
//NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.hp, 30, 15, "time_", this.coin, true);
}
startGame() {
// 获取场景中的 JiaZai 组件
const jiazaiNode = cc.find("Canvas"); // 假设 JiaZai 挂在 Canvas 节点
if (jiazaiNode) {
const jiazaiComp = jiazaiNode.getComponent(JiaZai);
if (jiazaiComp) {
jiazaiComp.startGame();
} else {
console.warn("JiaZai 组件未找到");
}
} else {
console.warn("JiaZai 节点未找到");
}
this.closePop();
}
//关闭弹窗
closePop() {
//销毁预制体
console.log("关闭heath弹窗");
this.heath.destroy();
}
// update (dt) {}
}