File tree Expand file tree Collapse file tree
packages/webgal/src/Core/gameScripts/changeBg Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -32,10 +32,15 @@ export const changeBg = (sentence: ISentence): IPerform => {
3232 dispatch ( unlockCgInUserData ( { name : unlockName , url, series } ) ) ;
3333 }
3434
35+ /**
36+ * 判断背景 URL 是否发生了变化
37+ */
38+ const isUrlChanged = webgalStore . getState ( ) . stage . bgName !== sentence . content ;
39+
3540 /**
3641 * 删掉相关 Effects,因为已经移除了
3742 */
38- if ( webgalStore . getState ( ) . stage . bgName !== sentence . content ) {
43+ if ( isUrlChanged ) {
3944 dispatch ( stageActions . removeEffectByTargetId ( `bg-main` ) ) ;
4045 }
4146
@@ -85,6 +90,17 @@ export const changeBg = (sentence: ISentence): IPerform => {
8590 duration = getAnimateDuration ( exitAnimation ) ;
8691 }
8792
93+ /**
94+ * 背景状态后处理
95+ */
96+ function postBgStateSet ( ) {
97+ if ( isUrlChanged ) {
98+ // 当 URL 发生变化时,清理旧的 hold 动画
99+ WebGAL . gameplay . performController . unmountPerform ( `animation-bg-main` , true ) ;
100+ }
101+ }
102+
103+ postBgStateSet ( ) ;
88104 dispatch ( setStage ( { key : 'bgName' , value : sentence . content } ) ) ;
89105
90106 return {
You can’t perform that action at this time.
0 commit comments