feat(任务卡片): 添加放弃选择功能并更新按钮事件处理
将关闭按钮的点击事件从直接关闭改为触发放弃选择功能 新增onGiveUp方法处理放弃逻辑,包括隐藏按钮和卡片动画
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭界面
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user