From ff86843887a099e49b5ce11f40a975381e52f84a Mon Sep 17 00:00:00 2001 From: Hardy--Lee Date: Fri, 6 Feb 2026 19:07:32 +0800 Subject: [PATCH] fix: keep animation error --- packages/webgal/src/Core/gameScripts/setAnimation.ts | 12 +++++++++--- .../webgal/src/Core/gameScripts/setTempAnimation.ts | 12 +++++++++--- packages/webgal/src/Core/gameScripts/setTransform.ts | 1 - 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/packages/webgal/src/Core/gameScripts/setAnimation.ts b/packages/webgal/src/Core/gameScripts/setAnimation.ts index 748b4498a..aa68a5bb4 100644 --- a/packages/webgal/src/Core/gameScripts/setAnimation.ts +++ b/packages/webgal/src/Core/gameScripts/setAnimation.ts @@ -13,7 +13,6 @@ import { WebGAL } from '@/Core/WebGAL'; * @param sentence */ export const setAnimation = (sentence: ISentence): IPerform => { - const startDialogKey = webgalStore.getState().stage.currentDialogKey; const animationName = sentence.content; const animationDuration = getAnimateDuration(animationName); let target = getStringArgByKey(sentence, 'target') ?? ''; @@ -23,11 +22,15 @@ export const setAnimation = (sentence: ISentence): IPerform => { const key = `${target}-${animationName}-${animationDuration}`; const performInitName = `animation-${target}`; + let keepAnimationStopped = false; WebGAL.gameplay.performController.unmountPerform(performInitName, true); let stopFunction; setTimeout(() => { + if (keep && keepAnimationStopped) { + return; + } WebGAL.gameplay.pixiStage?.stopPresetAnimationOnTarget(target); const animationObj: IAnimationObject | null = getAnimationObject( animationName, @@ -41,9 +44,12 @@ export const setAnimation = (sentence: ISentence): IPerform => { } }, 0); stopFunction = () => { + if (keep) { + WebGAL.gameplay.pixiStage?.removeAnimationWithoutSetEndState(key); + keepAnimationStopped = true; + return; + } setTimeout(() => { - const endDialogKey = webgalStore.getState().stage.currentDialogKey; - const isHasNext = startDialogKey !== endDialogKey; WebGAL.gameplay.pixiStage?.removeAnimationWithSetEffects(key); }, 0); }; diff --git a/packages/webgal/src/Core/gameScripts/setTempAnimation.ts b/packages/webgal/src/Core/gameScripts/setTempAnimation.ts index 8da9635f7..bd6f6964d 100644 --- a/packages/webgal/src/Core/gameScripts/setTempAnimation.ts +++ b/packages/webgal/src/Core/gameScripts/setTempAnimation.ts @@ -16,7 +16,6 @@ import { WebGAL } from '@/Core/WebGAL'; * @param sentence */ export const setTempAnimation = (sentence: ISentence): IPerform => { - const startDialogKey = webgalStore.getState().stage.currentDialogKey; const animationName = (Math.random() * 10).toString(16); const animationString = sentence.content; let animationObj; @@ -34,11 +33,15 @@ export const setTempAnimation = (sentence: ISentence): IPerform => { const key = `${target}-${animationName}-${animationDuration}`; const performInitName = `animation-${target}`; + let keepAnimationStopped = false; WebGAL.gameplay.performController.unmountPerform(performInitName, true); let stopFunction = () => {}; setTimeout(() => { + if (keep && keepAnimationStopped) { + return; + } WebGAL.gameplay.pixiStage?.stopPresetAnimationOnTarget(target); const animationObj: IAnimationObject | null = getAnimationObject( animationName, @@ -52,9 +55,12 @@ export const setTempAnimation = (sentence: ISentence): IPerform => { } }, 0); stopFunction = () => { + if (keep) { + WebGAL.gameplay.pixiStage?.removeAnimationWithoutSetEndState(key); + keepAnimationStopped = true; + return; + } setTimeout(() => { - const endDialogKey = webgalStore.getState().stage.currentDialogKey; - const isHasNext = startDialogKey !== endDialogKey; WebGAL.gameplay.pixiStage?.removeAnimationWithSetEffects(key); }, 0); }; diff --git a/packages/webgal/src/Core/gameScripts/setTransform.ts b/packages/webgal/src/Core/gameScripts/setTransform.ts index 149287293..5a53042ae 100644 --- a/packages/webgal/src/Core/gameScripts/setTransform.ts +++ b/packages/webgal/src/Core/gameScripts/setTransform.ts @@ -17,7 +17,6 @@ import { getAnimateDuration, getAnimationObject } from '../Modules/animationFunc * @param sentence */ export const setTransform = (sentence: ISentence): IPerform => { - const startDialogKey = webgalStore.getState().stage.currentDialogKey; const animationName = (Math.random() * 10).toString(16); const animationString = sentence.content; let animationObj: AnimationFrame[];