Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 6 additions & 4 deletions packages/webgal/src/Core/Modules/animationFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ export function getAnimateDuration(animationName: string) {
return 0;
}

// eslint-disable-next-line max-params
export function getEnterExitAnimation(
target: string,
type: 'enter' | 'exit',
isBg = false,
realTarget?: string, // 用于立绘和背景移除时,以当前时间打上特殊标记
): {
duration: number;
animation: {
Expand All @@ -57,11 +59,11 @@ export function getEnterExitAnimation(
setStartState: () => void;
tickerFunc: (delta: number) => void;
setEndState: () => void;
} | null = generateUniversalSoftInAnimationObj(target, duration);
} | null = generateUniversalSoftInAnimationObj(realTarget ?? target, duration);
const animarionName = WebGAL.animationManager.nextEnterAnimationName.get(target);
if (animarionName) {
logger.debug('取代默认进入动画', target);
animation = getAnimationObject(animarionName, target, getAnimateDuration(animarionName));
animation = getAnimationObject(animarionName, realTarget ?? target, getAnimateDuration(animarionName));
duration = getAnimateDuration(animarionName);
// 用后重置
WebGAL.animationManager.nextEnterAnimationName.delete(target);
Expand All @@ -77,11 +79,11 @@ export function getEnterExitAnimation(
setStartState: () => void;
tickerFunc: (delta: number) => void;
setEndState: () => void;
} | null = generateUniversalSoftOffAnimationObj(target, duration);
} | null = generateUniversalSoftOffAnimationObj(realTarget ?? target, duration);
const animarionName = WebGAL.animationManager.nextExitAnimationName.get(target);
if (animarionName) {
logger.debug('取代默认退出动画', target);
animation = getAnimationObject(animarionName, target, getAnimateDuration(animarionName));
animation = getAnimationObject(animarionName, realTarget ?? target, getAnimateDuration(animarionName));
duration = getAnimateDuration(animarionName);
// 用后重置
WebGAL.animationManager.nextExitAnimationName.delete(target);
Expand Down
12 changes: 7 additions & 5 deletions packages/webgal/src/Stage/MainStage/useSetBg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,15 @@ export function useSetBg(stageState: IStageState) {
function removeBg(bgObject: IStageObject) {
WebGAL.gameplay.pixiStage?.removeAnimationWithSetEffects('bg-main-softin');
const oldBgKey = bgObject.key;
bgObject.key = 'bg-main-off';
bgObject.key = 'bg-main-off' + String(new Date().getTime());
const bgKey = bgObject.key;
const bgAniKey = bgObject.key + '-softoff';
WebGAL.gameplay.pixiStage?.removeStageObjectByKey(oldBgKey);
const { duration, animation } = getEnterExitAnimation('bg-main-off', 'exit', true);
WebGAL.gameplay.pixiStage!.registerAnimation(animation, 'bg-main-softoff', 'bg-main-off');
const { duration, animation } = getEnterExitAnimation('bg-main-off', 'exit', true, bgKey);
WebGAL.gameplay.pixiStage!.registerAnimation(animation, bgAniKey, bgKey);
setTimeout(() => {
WebGAL.gameplay.pixiStage?.removeAnimation('bg-main-softoff');
WebGAL.gameplay.pixiStage?.removeStageObjectByKey('bg-main-off');
WebGAL.gameplay.pixiStage?.removeAnimation(bgAniKey);
WebGAL.gameplay.pixiStage?.removeStageObjectByKey(bgKey);
}, duration);
}

Expand Down
7 changes: 4 additions & 3 deletions packages/webgal/src/Stage/MainStage/useSetFigure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,12 @@ function removeFig(figObj: IStageObject, enterTikerKey: string, effects: IEffect
return;
}
const oldFigKey = figObj.key;
figObj.key = figObj.key + '-off';
WebGAL.gameplay.pixiStage?.removeStageObjectByKey(oldFigKey);
const figLeaveAniKey = oldFigKey + '-off';
figObj.key = oldFigKey + String(new Date().getTime()) + '-off';
const figKey = figObj.key;
WebGAL.gameplay.pixiStage?.removeStageObjectByKey(oldFigKey);
const leaveKey = figKey + '-softoff';
const { duration, animation } = getEnterExitAnimation(figKey, 'exit');
const { duration, animation } = getEnterExitAnimation(figLeaveAniKey, 'exit', false, figKey);
WebGAL.gameplay.pixiStage!.registerPresetAnimation(animation, leaveKey, figKey, effects);
setTimeout(() => {
WebGAL.gameplay.pixiStage?.removeAnimation(leaveKey);
Expand Down