refactor(map): 为技能抽卡添加入场动画效果
1. 新增技能卡入场动画逻辑,实现多张卡牌依次从下方飞入的效果 2. 调整技能抽卡弹窗显示流程,先刷新卡牌数据再播放动画 3. 清理代码中多余的空白行,优化格式整洁度
This commit is contained in:
@@ -375,11 +375,41 @@ export class MissionCardComp extends CCComp {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 技能卡入场动画:每个卡槽从场景基准位置下方 80px 处升起,
|
||||
* 终止位置 = 场景编辑器位置(保持初始不做位移的约束),
|
||||
* 多张依次错开 staggerDelay 形成"依次飞入"效果。
|
||||
*/
|
||||
private readonly skillEnterOffsetY: number = -80;
|
||||
private readonly skillEnterDuration: number = 0.25;
|
||||
private readonly skillEnterStagger: number = 0.08;
|
||||
|
||||
private playSkillCardEnterAnim() {
|
||||
if (!this.skillCardComps || this.skillCardComps.length === 0) return;
|
||||
for (let i = 0; i < this.skillCardComps.length; i++) {
|
||||
const comp = this.skillCardComps[i];
|
||||
if (!comp) continue;
|
||||
const node = comp.node;
|
||||
if (!node || !node.isValid) continue;
|
||||
// 缓存场景编辑器位置作为动画终止点(初始不做位移)
|
||||
const basePos = node.getPosition();
|
||||
// 起始位置 = 基准位置下移 80px
|
||||
node.setPosition(basePos.x, basePos.y + this.skillEnterOffsetY, basePos.z);
|
||||
Tween.stopAllByTarget(node);
|
||||
tween(node)
|
||||
.delay(i * this.skillEnterStagger)
|
||||
.to(this.skillEnterDuration, { position: basePos }, { easing: 'quadOut' })
|
||||
.start();
|
||||
}
|
||||
}
|
||||
|
||||
private showSkillCardPopup() {
|
||||
if (!this.skill_card_node) return;
|
||||
this.skill_card_node.active = true;
|
||||
// 先分发卡牌数据(让卡面内容就绪),再做入场动画
|
||||
const cards = this.buildSkillDrawCards();
|
||||
this.dispatchCardsToSkillSlots(cards);
|
||||
this.playSkillCardEnterAnim();
|
||||
}
|
||||
|
||||
private dispatchCardsToSkillSlots(cards: CardConfig[]) {
|
||||
|
||||
Reference in New Issue
Block a user