feat(CardComp): add coin insufficient prompt feature
1. 新增金币不足提示节点配置与显示逻辑 2. 优化等级文本的分隔符为更直观的箭头符号 3. 修复提示节点未默认隐藏的问题
This commit is contained in:
@@ -97,6 +97,9 @@ export class CardComp extends CCComp {
|
||||
ap_node = null!
|
||||
@property(Node)
|
||||
hp_node = null!
|
||||
/** 金币不足提示节点(useCard 费用不足时显示 2 秒) */
|
||||
@property(Node)
|
||||
no_cion_node = null!
|
||||
|
||||
// ======================== 运行时状态 ========================
|
||||
|
||||
@@ -147,6 +150,8 @@ export class CardComp extends CCComp {
|
||||
this.applyEmptyUI();
|
||||
// call_btn 默认隐藏,仅在点击本卡时显示
|
||||
this.hideCallBtn();
|
||||
// 金币不足提示默认隐藏
|
||||
if (this.no_cion_node) this.no_cion_node.active = false;
|
||||
}
|
||||
|
||||
/** 组件销毁时解绑所有事件,防止残留回调 */
|
||||
@@ -307,6 +312,8 @@ export class CardComp extends CCComp {
|
||||
if (!success) {
|
||||
oops.message.dispatchEvent(GameEvent.ShowSmallTip, "buy_coin");
|
||||
this.playReboundAnim();
|
||||
// 显示"金币不足"提示节点 2 秒
|
||||
this.showNoCoinNode();
|
||||
mLogger.log(this.debugMode, "CardComp", "use card coin not enough", {
|
||||
uuid: this.cardData.uuid,
|
||||
type: this.cardData.type,
|
||||
@@ -754,7 +761,7 @@ export class CardComp extends CCComp {
|
||||
if (this.lvl_node) {
|
||||
// 升级卡:显示「当前→升级后」;普通英雄卡:显示当前等级。统一使用默认颜色
|
||||
if (isUpgradeCard && heroLv > 1) {
|
||||
this.lvl_node.string = `Lv.${heroLv - 1} Lv.${heroLv}`;
|
||||
this.lvl_node.string = `Lv.${heroLv - 1} -> Lv.${heroLv}`;
|
||||
} else {
|
||||
this.lvl_node.string = `Lv.${heroLv}`;
|
||||
}
|
||||
@@ -844,6 +851,26 @@ export class CardComp extends CCComp {
|
||||
.start();
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示"金币不足"提示节点,2 秒后自动隐藏。
|
||||
* Why: useCard 金币不足时给玩家明确的视觉反馈。
|
||||
* 使用 scheduleOnce 与组件生命周期绑定,组件销毁时自动清理。
|
||||
*/
|
||||
private showNoCoinNode() {
|
||||
if (!this.no_cion_node) return;
|
||||
// 清理上一次的隐藏回调,避免连续触发时被提前关闭
|
||||
this.unschedule(this.hideNoCoinNode);
|
||||
this.no_cion_node.active = true;
|
||||
this.scheduleOnce(this.hideNoCoinNode, 2);
|
||||
}
|
||||
|
||||
/** 隐藏"金币不足"提示节点 */
|
||||
private hideNoCoinNode() {
|
||||
if (this.no_cion_node && this.no_cion_node.isValid) {
|
||||
this.no_cion_node.active = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用消失动画:
|
||||
* - 节点从当前位置向上移动 120px(X 轴保持当前值不变,不使用 restPosition.x)
|
||||
|
||||
Reference in New Issue
Block a user