From b1a25d1d0e127ad932c9de7363e1e4bbaaadaf2b Mon Sep 17 00:00:00 2001 From: walkpan Date: Tue, 6 Jan 2026 11:14:00 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E4=BB=BB=E5=8A=A1=E5=8D=A1=E7=89=87):=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=94=BE=E5=BC=83=E9=80=89=E6=8B=A9=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E5=B9=B6=E6=9B=B4=E6=96=B0=E6=8C=89=E9=92=AE=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将关闭按钮的点击事件从直接关闭改为触发放弃选择功能 新增onGiveUp方法处理放弃逻辑,包括隐藏按钮和卡片动画 --- assets/script/game/map/MissionCardComp.ts | 29 +++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/assets/script/game/map/MissionCardComp.ts b/assets/script/game/map/MissionCardComp.ts index dde57a65..93f26229 100644 --- a/assets/script/game/map/MissionCardComp.ts +++ b/assets/script/game/map/MissionCardComp.ts @@ -45,7 +45,7 @@ export class MissionCardComp extends CCComp { onLoad() { if (this.btnClose) { - this.btnClose.on(Node.EventType.TOUCH_END, this.close, this); + this.btnClose.on(Node.EventType.TOUCH_END, this.onGiveUp, this); } oops.message.on(GameEvent.TalentSelect, this.onTalentSelect, this); @@ -59,7 +59,7 @@ export class MissionCardComp extends CCComp { onDestroy() { if (this.btnClose) { - this.btnClose.off(Node.EventType.TOUCH_END, this.close, this); + this.btnClose.off(Node.EventType.TOUCH_END, this.onGiveUp, this); } oops.message.off(GameEvent.TalentSelect, this.onTalentSelect, this); @@ -371,6 +371,31 @@ export class MissionCardComp extends CCComp { } } + /** 放弃选择 */ + onGiveUp() { + if (this.hasSelected) return; + this.hasSelected = true; + + // 隐藏关闭按钮 + if (this.btnClose) { + this.btnClose.active = false; + } + + const cards = [this.card1, this.card2, this.card3, this.card4]; + let delayTime = 0.2; + + cards.forEach(card => { + if (card && card.active) { + tween(card).to(delayTime, { scale: Vec3.ZERO }).start(); + } + }); + + // 动画结束后关闭 + this.scheduleOnce(() => { + this.close(); + }, delayTime); + } + /** * 关闭界面 */