Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,11 @@ export default class PixiStage {
this.removeAnimationByIndex(index);
}

public removeAnimationByTargetKey(targetKey: string) {
const index = this.stageAnimations.findIndex((e) => e.targetKey === targetKey);
this.removeAnimationByIndex(index);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

目前的实现使用了 findIndex,它只会找到并移除第一个匹配 targetKey 的动画。如果一个目标上可能存在多个动画,这可能会导致其他动画仍在运行。

为了确保移除目标上的所有动画,建议使用循环来查找并移除所有匹配的动画。这样可以使该功能在处理边缘情况时更加健壮。

    let index;
    while ((index = this.stageAnimations.findIndex((e) => e.targetKey === targetKey)) !== -1) {
      this.removeAnimationByIndex(index);
    }

}

public removeAnimationWithSetEffects(key: string) {
const index = this.stageAnimations.findIndex((e) => e.key === key);
if (index >= 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export const webSocketFunc = () => {
...(effect.transform?.scale ?? {}),
},
};
WebGAL.gameplay.pixiStage?.removeAnimationByTargetKey(effect.target);
webgalStore.dispatch(stageActions.updateEffect({ target: effect.target, transform: newTransform }));
} catch (e) {
logger.error(`无法设置效果 ${message.message}, ${e}`);
Expand Down
Loading