fix(卡牌): 处理卡牌使用失败时的状态回弹

当卡牌因条件不足(如金币不够)使用失败时,不再直接消失,而是播放回弹动画并恢复原状。同时修复了卡牌取消放大时位置可能被重置的问题。
This commit is contained in:
panw
2026-04-24 15:22:33 +08:00
parent 7047ba932e
commit 70130cb930
2 changed files with 1930 additions and 1778 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -575,17 +575,29 @@ export class CardComp extends CCComp {
this.isDragging = false; this.isDragging = false;
if (deltaY >= this.dragUseThreshold) { if (deltaY >= this.dragUseThreshold) {
this.useCard(); const used = this.useCard();
// 使用卡牌后恢复非放大状态 if (!used) {
// 使用失败(如金币不足),恢复未放大状态并回弹
this.isEnlarged = false; this.isEnlarged = false;
this.isLongPressed = false; this.isLongPressed = false;
const currentPos = this.node.position.clone();
this.applyCardUI();
this.node.setPosition(currentPos);
this.playReboundAnim();
} else {
// 使用成功,恢复非放大状态
this.isEnlarged = false;
this.isLongPressed = false;
}
return; return;
} }
// 无论是点击还是长按松手,都恢复正常大小 // 无论是点击还是长按松手,都恢复正常大小
if (this.isEnlarged) { if (this.isEnlarged) {
this.isEnlarged = false; this.isEnlarged = false;
const currentPos = this.node.position.clone();
this.applyCardUI(); this.applyCardUI();
this.node.setPosition(currentPos);
} }
this.isLongPressed = false; this.isLongPressed = false;
@@ -600,7 +612,9 @@ export class CardComp extends CCComp {
if (this.isEnlarged) { if (this.isEnlarged) {
this.isEnlarged = false; this.isEnlarged = false;
const currentPos = this.node.position.clone();
this.applyCardUI(); this.applyCardUI();
this.node.setPosition(currentPos);
} }
this.isLongPressed = false; this.isLongPressed = false;