|
|
@@ -9,6 +9,15 @@ const { ccclass, property } = _decorator;
|
|
|
@ccclass('SkillButtonAnimator')
|
|
|
export class SkillButtonAnimator extends Component {
|
|
|
|
|
|
+ private _origScale: Vec3 = new Vec3();
|
|
|
+ private _origPos: Vec3 = new Vec3();
|
|
|
+
|
|
|
+ onLoad () {
|
|
|
+ // 记录初始位置、缩放,用于恢复
|
|
|
+ this._origScale.set(this.node.scale);
|
|
|
+ this._origPos.set(this.node.position);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 播放缩小并(可选)移动到指定目标位置的动画。
|
|
|
* @param duration 动画时长(秒)
|
|
|
@@ -25,12 +34,12 @@ export class SkillButtonAnimator extends Component {
|
|
|
tween(this.node)
|
|
|
.to(duration, props, { easing: 'quadIn' })
|
|
|
.call(() => {
|
|
|
- this.node.active = false; // 动画结束后隐藏节点
|
|
|
- if (onComplete) {
|
|
|
- onComplete();
|
|
|
- }
|
|
|
+ // 动画结束后隐藏节点,但允许后续 resetState 恢复
|
|
|
+ this.node.active = false;
|
|
|
+ if (onComplete) onComplete();
|
|
|
})
|
|
|
.start();
|
|
|
+ this.node.setPosition(this._origPos);
|
|
|
}
|
|
|
}
|
|
|
|