Skip to content

Commit abe73d2

Browse files
Merge pull request #734 from HardyNLee/fix-sync-animation-missing
fix: missing sync animation
2 parents 072ede4 + 09340cd commit abe73d2

File tree

7 files changed

+31
-12
lines changed

7 files changed

+31
-12
lines changed

packages/webgal/src/Core/Modules/animationFunctions.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,12 @@ export function getEnterExitAnimation(
6262
}
6363
// 走默认动画
6464
let animation: IAnimationObject | null = generateUniversalSoftInAnimationObj(realTarget ?? target, duration);
65+
66+
const transformState = webgalStore.getState().stage.effects;
67+
const targetEffect = transformState.find((effect) => effect.target === target);
68+
6569
const animarionName = WebGAL.animationManager.nextEnterAnimationName.get(target);
66-
if (animarionName) {
70+
if (animarionName && !targetEffect) {
6771
logger.debug('取代默认进入动画', target);
6872
animation = getAnimationObject(animarionName, realTarget ?? target, getAnimateDuration(animarionName), false);
6973
duration = getAnimateDuration(animarionName);

packages/webgal/src/Core/Modules/gamePlay.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ export class Gameplay {
1313
public pixiStage: PixiStage | null = null;
1414
public performController = new PerformController();
1515
public resetGamePlay() {
16-
this.performController.timeoutList = [];
1716
this.isAuto = false;
1817
this.isFast = false;
1918
const autoInterval = this.autoInterval;

packages/webgal/src/Core/Modules/perform/performController.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ export const getRandomPerformName = (): string => {
1616

1717
export class PerformController {
1818
public performList: Array<IPerform> = [];
19-
public timeoutList: Array<ReturnType<typeof setTimeout>> = [];
2019

2120
public arrangeNewPerform(perform: IPerform, script: ISentence, syncPerformState = true) {
2221
// 检查演出列表内是否有相同的演出,如果有,一定是出了什么问题
@@ -108,12 +107,10 @@ export class PerformController {
108107

109108
public removeAllPerform() {
110109
for (const e of this.performList) {
110+
clearTimeout(e.stopTimeout);
111111
e.stopFunction();
112112
}
113113
this.performList = [];
114-
for (const e of this.timeoutList) {
115-
clearTimeout(e);
116-
}
117114
}
118115

119116
private goNextWhenOver() {

packages/webgal/src/Core/controller/stage/pixi/PixiController.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@ import { v4 as uuid } from 'uuid';
33
import { webgalStore } from '@/store/store';
44
import { setStage, stageActions } from '@/store/stageReducer';
55
import cloneDeep from 'lodash/cloneDeep';
6-
import { baseTransform, IEffect, IFigureAssociatedAnimation, IFigureMetadata, ITransform } from '@/store/stageInterface';
6+
import {
7+
baseTransform,
8+
IEffect,
9+
IFigureAssociatedAnimation,
10+
IFigureMetadata,
11+
ITransform,
12+
} from '@/store/stageInterface';
713
import { logger } from '@/Core/util/logger';
814
import { isIOS } from '@/Core/initializeScript';
915
import { WebGALPixiContainer } from '@/Core/controller/stage/pixi/WebGALPixiContainer';
@@ -75,7 +81,7 @@ export default class PixiStage {
7581
* 当前的 PIXI App
7682
*/
7783
public currentApp: PIXI.Application | null = null;
78-
public readonly mainStageContainer : WebGALPixiContainer;
84+
public readonly mainStageContainer: WebGALPixiContainer;
7985
public readonly foregroundEffectsContainer: PIXI.Container;
8086
public readonly backgroundEffectsContainer: PIXI.Container;
8187
public frameDuration = 16.67;
@@ -258,8 +264,7 @@ export default class PixiStage {
258264
* 移除动画
259265
* @param key
260266
*/
261-
public removeAnimation(key: string) {
262-
const index = this.stageAnimations.findIndex((e) => e.key === key);
267+
public removeAnimationByIndex(index: number) {
263268
if (index >= 0) {
264269
const thisTickerFunc = this.stageAnimations[index];
265270
this.currentApp?.ticker.remove(thisTickerFunc.animationObject.tickerFunc);
@@ -269,6 +274,17 @@ export default class PixiStage {
269274
}
270275
}
271276

277+
public removeAllAnimations() {
278+
while (this.stageAnimations.length > 0) {
279+
this.removeAnimationByIndex(0);
280+
}
281+
}
282+
283+
public removeAnimation(key: string) {
284+
const index = this.stageAnimations.findIndex((e) => e.key === key);
285+
this.removeAnimationByIndex(index);
286+
}
287+
272288
public removeAnimationWithSetEffects(key: string) {
273289
const index = this.stageAnimations.findIndex((e) => e.key === key);
274290
if (index >= 0) {

packages/webgal/src/Core/controller/stage/resetStage.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export const resetStage = (resetBacklog: boolean, resetSceneAndVar = true) => {
1616
}
1717

1818
// 清空所有演出和timeOut
19+
WebGAL.gameplay.pixiStage?.removeAllAnimations();
1920
WebGAL.gameplay.performController.removeAllPerform();
2021
WebGAL.gameplay.resetGamePlay();
2122

packages/webgal/src/Core/gameScripts/changeBg/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ export const changeBg = (sentence: ISentence): IPerform => {
3838
/**
3939
* 删掉相关 Effects,因为已经移除了
4040
*/
41-
dispatch(stageActions.removeEffectByTargetId(`bg-main`));
41+
if (webgalStore.getState().stage.bgName !== sentence.content) {
42+
dispatch(stageActions.removeEffectByTargetId(`bg-main`));
43+
}
4244

4345
// 处理 transform 和 默认 transform
4446
const transformString = getSentenceArgByKey(sentence, 'transform');

packages/webgal/src/store/stageReducer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export const initState: IStageState = {
5252
{
5353
target: 'stage-main',
5454
transform: baseTransform,
55-
}
55+
},
5656
],
5757
bgFilter: '', // 现在不用,先预留
5858
bgTransform: '', // 现在不用,先预留

0 commit comments

Comments
 (0)