fix(卡牌): 处理卡牌使用失败时的状态回弹
当卡牌因条件不足(如金币不够)使用失败时,不再直接消失,而是播放回弹动画并恢复原状。同时修复了卡牌取消放大时位置可能被重置的问题。
This commit is contained in:
@@ -575,17 +575,29 @@ export class CardComp extends CCComp {
|
||||
this.isDragging = false;
|
||||
|
||||
if (deltaY >= this.dragUseThreshold) {
|
||||
this.useCard();
|
||||
// 使用卡牌后恢复非放大状态
|
||||
this.isEnlarged = false;
|
||||
this.isLongPressed = false;
|
||||
const used = this.useCard();
|
||||
if (!used) {
|
||||
// 使用失败(如金币不足),恢复未放大状态并回弹
|
||||
this.isEnlarged = 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;
|
||||
}
|
||||
|
||||
// 无论是点击还是长按松手,都恢复正常大小
|
||||
if (this.isEnlarged) {
|
||||
this.isEnlarged = false;
|
||||
const currentPos = this.node.position.clone();
|
||||
this.applyCardUI();
|
||||
this.node.setPosition(currentPos);
|
||||
}
|
||||
|
||||
this.isLongPressed = false;
|
||||
@@ -600,7 +612,9 @@ export class CardComp extends CCComp {
|
||||
|
||||
if (this.isEnlarged) {
|
||||
this.isEnlarged = false;
|
||||
const currentPos = this.node.position.clone();
|
||||
this.applyCardUI();
|
||||
this.node.setPosition(currentPos);
|
||||
}
|
||||
|
||||
this.isLongPressed = false;
|
||||
|
||||
Reference in New Issue
Block a user