전환
디졸브, 페이드, 무브, 푸시, 줌 전환을 비롯해 Pixi’VN이 canvas 컴포넌트를 표시하고 제거하기 위해 제공하는 내장 전환 효과에 대해 알아보세요. 게임 흐름에 고급 시각 효과를 적용하기 위해 전환을 커스터마이즈하거나 직접 만드는 방법을 알아보세요.
Pixi’VN은 canvas 컴포넌트를 표시하거나 제거하기 위한 다양한 전환 효과를 제공하며, 나만의 전환 만들기 기능도 제공합니다.
디졸브 전환:
- 컴포넌트를 표시할 때
alpha를 점차 증가시킵니다. 동일한 alias를 가진 컴포넌트가 존재하는 경우, 새 컴포넌트의 전환이 완료되면 기존 컴포넌트가 제거됩니다. - 컴포넌트를 제거할 때
alpha를 점차 감소시킵니다.
The transitions.showWithDissolve function displays a canvas element with a dissolve transition.
The transitions.removeWithDissolve function removes a canvas element with a dissolve transition.
import { newLabel, transitions } from "@drincs/pixi-vn";
export const startLabel = newLabel("start", [
async () => {
await transitions.showWithDissolve("alien", "egg_head");
await transitions.showWithDissolve("human", {
value: ["m01-body", "m01-eyes", "m01-mouth"],
options: { scale: 0.5, xAlign: 0.7 },
});
},
async () => {
await transitions.showWithDissolve("alien", "flower_top");
transitions.removeWithDissolve("human");
},
]);페이드 전환:
- 컴포넌트를 표시할 때
alpha를 점차 증가시킵니다. 동일한 alias를 가진 컴포넌트가 존재하는 경우, 새 컴포넌트가 표시되기 전에 기존 컴포넌트가 페이드 아웃 효과와 함께 제거됩니다. - 컴포넌트를 제거할 때
alpha를 점차 감소시킵니다.
The transitions.showWithFade function displays a canvas element with a fade transition.
The transitions.removeWithFade function removes a canvas element with a fade transition.
import { newLabel, transitions } from "@drincs/pixi-vn";
export const startLabel = newLabel("start", [
async () => {
await transitions.showWithFade("alien", "egg_head", { duration: 5 });
await transitions.showWithFade("human", {
value: ["m01-body", "m01-eyes", "m01-mouth"],
options: { scale: 0.5, xAlign: 0.7 },
});
},
async () => {
await transitions.showWithFade("alien", "flower_top");
transitions.removeWithFade("human");
},
]);무브 인/아웃 전환:
- 컴포넌트를 표시할 때, (오른쪽, 왼쪽, 위쪽, 아래쪽 등) 바깥에서 canvas 상의 위치로 이동시킵니다. 동일한 alias를 가진 컴포넌트가 존재하는 경우, 새 컴포넌트가 표시되기 전에 기존 컴포넌트가 무브 아웃 효과와 함께 제거됩니다.
- 컴포넌트를 제거할 때, 해당 위치에서 canvas 바깥으로 이동시킵니다.
The transitions.moveIn function displays a canvas element with a move-in transition.
The transitions.moveOut function removes a canvas element with a move-out transition.
import { newLabel, transitions } from "@drincs/pixi-vn";
export const startLabel = newLabel("start", [
async () => {
await transitions.moveIn("alien", "egg_head", { direction: "up" });
await transitions.moveIn("human", {
value: ["m01-body", "m01-eyes", "m01-mouth"],
options: { scale: 0.5, xAlign: 0.7 },
});
},
async () => {
await transitions.moveIn("alien", "flower_top", { direction: "up" });
transitions.moveOut("human");
},
]);푸시 인/아웃 전환:
- 컴포넌트를 표시할 때, (오른쪽, 왼쪽, 위쪽, 아래쪽 등) 바깥에서 canvas 상의 위치로 이동시킵니다. 동일한 alias를 가진 컴포넌트가 존재하는 경우, 새 컴포넌트가 들어오는 동안 기존 컴포넌트가 푸시 아웃 효과와 함께 제거됩니다.
- 컴포넌트를 제거할 때, 해당 위치에서 canvas 바깥으로 이동시킵니다.
The transitions.pushIn function displays a canvas element with a push-in transition.
The transitions.pushOut function removes a canvas element with a push-out transition.
import { newLabel, transitions } from "@drincs/pixi-vn";
export const startLabel = newLabel("start", [
async () => {
await transitions.pushIn("alien", "egg_head");
await transitions.pushIn("human", {
value: ["m01-body", "m01-eyes", "m01-mouth"],
options: { scale: 0.5, xAlign: 0.7 },
});
},
async () => {
await transitions.pushIn("alien", "flower_top", { direction: "up" });
transitions.pushOut("human");
},
]);줌 인/아웃 전환:
- 컴포넌트를 표시할 때, (canvas 바깥에서) 크기 0에서 원래 크기와 위치로 확대시킵니다. 동일한 alias를 가진 컴포넌트가 존재하는 경우, 새 컴포넌트의 전환이 완료되면 기존 컴포넌트가 제거됩니다.
- 컴포넌트를 제거할 때, 원래 크기에서 0으로 축소시키며 canvas 바깥으로 이동시킵니다.
The transitions.zoomIn function displays a canvas element with a zoom-in transition.
The transitions.zoomOut function removes a canvas element with a zoom-out transition.
import { newLabel, transitions } from "@drincs/pixi-vn";
export const startLabel = newLabel("start", [
async () => {
await transitions.zoomIn("alien", "egg_head");
await transitions.zoomIn("human", {
value: ["m01-body", "m01-eyes", "m01-mouth"],
options: { scale: 0.5, xAlign: 0.7 },
});
},
async () => {
await transitions.zoomIn("alien", "flower_top");
transitions.zoomOut("human");
},
]);This animation was introduced in version v1.9.5.
The wipe in/out transition reveals or conceals a component using a moving boundary. It is a single generic primitive rather than separate wipeLeft/wipeRight functions: the boundary's angle (or a direction shorthand), edge softness, and invert are all configurable, so the same primitive can produce horizontal, vertical, diagonal, hard-edged, or soft-edged reveals.
- When showing a component, progressively reveals it as the boundary sweeps across. 동일한 alias를 가진 컴포넌트가 존재하는 경우, 새 컴포넌트의 전환이 완료되면 기존 컴포넌트가 제거됩니다.
- When removing a component, progressively conceals it as the boundary sweeps across.
The transitions.wipeIn function displays a canvas element with a wipe-in transition.
The transitions.wipeOut function removes a canvas element with a wipe-out transition.
import { newLabel, transitions } from "@drincs/pixi-vn";
export const startLabel = newLabel("start", [
async () => {
await transitions.wipeIn("alien", "egg_head");
await transitions.wipeIn("human", {
value: ["m01-body", "m01-eyes", "m01-mouth"],
options: { scale: 0.5, xAlign: 0.7 },
});
},
async () => {
await transitions.wipeIn("alien", "flower_top", { angle: 45, softness: 30 });
transitions.wipeOut("human");
},
]);This animation was introduced in version v1.9.5.
The iris in/out transition reveals or conceals a component using an expanding or contracting radial mask. A centered circular iris is only one configuration: moving origin off-center (normalized to the component's own bounds) makes the same primitive useful as a focus/reveal effect centered on a character, and aspect turns the circle into a wide or tall ellipse.
- When showing a component, the mask expands from
originto progressively reveal it. 동일한 alias를 가진 컴포넌트가 존재하는 경우, 새 컴포넌트의 전환이 완료되면 기존 컴포넌트가 제거됩니다. - When removing a component, the mask contracts back towards
originto progressively conceal it.
The transitions.irisIn function displays a canvas element with an iris-in transition.
The transitions.irisOut function removes a canvas element with an iris-out transition.
import { newLabel, transitions } from "@drincs/pixi-vn";
export const startLabel = newLabel("start", [
async () => {
await transitions.irisIn("alien", "egg_head");
await transitions.irisIn("human", {
value: ["m01-body", "m01-eyes", "m01-mouth"],
options: { scale: 0.5, xAlign: 0.7 },
});
},
async () => {
await transitions.irisIn("alien", "flower_top", {
origin: { x: 0.2, y: 0.8 },
softness: 25,
});
transitions.irisOut("human");
},
]);This animation was introduced in version v1.9.5.
The split in/out transition reveals or conceals a component using two mask panels that move apart or together. It covers "curtain"-like effects without a dedicated, story-specific API: orientation picks whether the panels split vertically or horizontally, and origin moves the split line off-center.
- When showing a component, the two panels slide together from the edges to progressively reveal it, meeting at the split line once fully shown. 동일한 alias를 가진 컴포넌트가 존재하는 경우, 새 컴포넌트의 전환이 완료되면 기존 컴포넌트가 제거됩니다.
- When removing a component, the two panels retract apart towards the edges to progressively conceal it.
The transitions.splitIn function displays a canvas element with a split-in transition.
The transitions.splitOut function removes a canvas element with a split-out transition.
import { newLabel, transitions } from "@drincs/pixi-vn";
export const startLabel = newLabel("start", [
async () => {
await transitions.splitIn("alien", "egg_head");
await transitions.splitIn("human", {
value: ["m01-body", "m01-eyes", "m01-mouth"],
options: { scale: 0.5, xAlign: 0.7 },
});
},
async () => {
await transitions.splitIn("alien", "flower_top", {
orientation: "horizontal",
origin: 0.25,
});
transitions.splitOut("human");
},
]);This animation was introduced in version v1.9.5.
The flash in/out transition plays a configurable solid-color overlay that fades in, optionally holds, and fades back out — not limited to a white flash. White reads as a camera/explosion-like flash, black behaves like a blink/cut, and arbitrary colors work for damage, magic, memory, or UI transitions. pulses repeats the fade-in/hold/fade-out cycle for a multi-flash effect (e.g. a damage flash).
- When showing a component, the new component appears immediately and the overlay plays over it.
- When removing a component, the overlay plays over it and it is then removed.
The transitions.flashIn function displays a canvas element with a flash-in transition.
The transitions.flashOut function removes a canvas element with a flash-out transition.
import { newLabel, transitions } from "@drincs/pixi-vn";
export const startLabel = newLabel("start", [
async () => {
await transitions.flashIn("alien", "egg_head");
await transitions.flashIn("human", {
value: ["m01-body", "m01-eyes", "m01-mouth"],
options: { scale: 0.5, xAlign: 0.7 },
});
},
async () => {
await transitions.flashIn("alien", "flower_top", {
color: 0xff0033,
holdDuration: 0.05,
pulses: 3,
});
transitions.flashOut("human", { color: 0x000000 });
},
]);This animation was introduced in version v1.9.5.
The blur in/out transition animates blur strength into or out of focus. It is a generic blur, not a "dream"/"flashback" transition specifically — combine it with showWithFade for that recipe (see custom functionality below for building recipes).
- When showing a component, it appears already blurred and sharpens into focus. 동일한 alias를 가진 컴포넌트가 존재하는 경우, 새 컴포넌트의 전환이 완료되면 기존 컴포넌트가 제거됩니다.
- When removing a component, it blurs out of focus before being removed.
The transitions.blurIn function displays a canvas element with a blur-in transition.
The transitions.blurOut function removes a canvas element with a blur-out transition.
import { newLabel, transitions } from "@drincs/pixi-vn";
export const startLabel = newLabel("start", [
async () => {
await transitions.blurIn("alien", "egg_head");
await transitions.blurIn("human", {
value: ["m01-body", "m01-eyes", "m01-mouth"],
options: { scale: 0.5, xAlign: 0.7 },
});
},
async () => {
await transitions.blurIn("alien", "flower_top", { strength: 60, quality: 6 });
transitions.blurOut("human");
},
]);This animation was introduced in version v1.9.5.
The pixelate in/out transition animates pixelation strength into or out of focus. Useful for retro effects, digital transitions, censorship/stylization, or scene changes — not only "glitch" scenes.
- When showing a component, it appears already pixelated and resolves into focus. 동일한 alias를 가진 컴포넌트가 존재하는 경우, 새 컴포넌트의 전환이 완료되면 기존 컴포넌트가 제거됩니다.
- When removing a component, it pixelates into blocks before being removed.
The transitions.pixelateIn function displays a canvas element with a pixelate-in transition.
The transitions.pixelateOut function removes a canvas element with a pixelate-out transition.
import { newLabel, transitions } from "@drincs/pixi-vn";
export const startLabel = newLabel("start", [
async () => {
await transitions.pixelateIn("alien", "egg_head");
await transitions.pixelateIn("human", {
value: ["m01-body", "m01-eyes", "m01-mouth"],
options: { scale: 0.5, xAlign: 0.7 },
});
},
async () => {
await transitions.pixelateIn("alien", "flower_top", { pixelSize: 64 });
transitions.pixelateOut("human");
},
]);This animation was introduced in version v1.9.5.
The glitch in/out transition builds up (or dies down) digital-corruption bursts: displaced slices and, optionally, an RGB channel split.
- When showing a component, glitch bursts fade out until the image settles clean. 동일한 alias를 가진 컴포넌트가 존재하는 경우, 새 컴포넌트의 전환이 완료되면 기존 컴포넌트가 제거됩니다.
- When removing a component, glitch bursts build up until the image is removed.
The transitions.glitchIn function displays a canvas element with a glitch-in transition.
The transitions.glitchOut function removes a canvas element with a glitch-out transition.
import { newLabel, transitions } from "@drincs/pixi-vn";
export const startLabel = newLabel("start", [
async () => {
await transitions.glitchIn("alien", "egg_head");
await transitions.glitchIn("human", {
value: ["m01-body", "m01-eyes", "m01-mouth"],
options: { scale: 0.5, xAlign: 0.7 },
});
},
async () => {
await transitions.glitchIn("alien", "flower_top", { strength: 60, bursts: 4, rgbSplit: 10 });
transitions.glitchOut("human");
},
]);This animation was introduced in version v1.9.5.
The twist in/out transition unwinds (or winds up) a component out of a swirl, like coming through a vortex or portal.
- When showing a component, it unwinds out of a swirl into its normal shape. 동일한 alias를 가진 컴포넌트가 존재하는 경우, 새 컴포넌트의 전환이 완료되면 기존 컴포넌트가 제거됩니다.
- When removing a component, it winds up into a swirl before being removed.
The transitions.twistIn function displays a canvas element with a twist-in transition.
The transitions.twistOut function removes a canvas element with a twist-out transition.
import { newLabel, transitions } from "@drincs/pixi-vn";
export const startLabel = newLabel("start", [
async () => {
await transitions.twistIn("alien", "egg_head");
await transitions.twistIn("human", {
value: ["m01-body", "m01-eyes", "m01-mouth"],
options: { scale: 0.5, xAlign: 0.7 },
});
},
async () => {
await transitions.twistIn("alien", "flower_top", { angle: 720 });
transitions.twistOut("human");
},
]);This animation was introduced in version v1.9.5.
The warp in/out transition arrives (or leaves) through radial zoom-blur streaks, like dropping out of (or into) hyperspace.
- When showing a component, it arrives out of radial zoom-blur streaks into focus. 동일한 alias를 가진 컴포넌트가 존재하는 경우, 새 컴포넌트의 전환이 완료되면 기존 컴포넌트가 제거됩니다.
- When removing a component, it streaks away in a radial zoom blur before being removed.
The transitions.warpIn function displays a canvas element with a warp-in transition.
The transitions.warpOut function removes a canvas element with a warp-out transition.
import { newLabel, transitions } from "@drincs/pixi-vn";
export const startLabel = newLabel("start", [
async () => {
await transitions.warpIn("alien", "egg_head");
await transitions.warpIn("human", {
value: ["m01-body", "m01-eyes", "m01-mouth"],
options: { scale: 0.5, xAlign: 0.7 },
});
},
async () => {
await transitions.warpIn("alien", "flower_top", { strength: 0.8 });
transitions.warpOut("human");
},
]);This animation was introduced in version v1.9.5.
The ripple in/out transition fades a component in (or out) through a ring of water-like distortion spreading outward from an origin point - useful for dreams, magic, or memories.
- When showing a component, it fades in through an outward-spreading ripple. 동일한 alias를 가진 컴포넌트가 존재하는 경우, 새 컴포넌트의 전환이 완료되면 기존 컴포넌트가 제거됩니다.
- When removing a component, a ripple spreads over it as it fades out and is removed.
The transitions.rippleIn function displays a canvas element with a ripple-in transition.
The transitions.rippleOut function removes a canvas element with a ripple-out transition.
import { newLabel, transitions } from "@drincs/pixi-vn";
export const startLabel = newLabel("start", [
async () => {
await transitions.rippleIn("alien", "egg_head");
await transitions.rippleIn("human", {
value: ["m01-body", "m01-eyes", "m01-mouth"],
options: { scale: 0.5, xAlign: 0.7 },
});
},
async () => {
await transitions.rippleIn("alien", "flower_top", { origin: { x: 0.2, y: 0.8 }, amplitude: 45 });
transitions.rippleOut("human");
},
]);This animation was introduced in version v1.9.5.
The noise dissolve in/out transition is the classic visual-novel image dissolve: the component appears (or disappears) in organic, noise-shaped blotches, or as a cloudy fade with edge: "soft".
- When showing a component, it appears in noise-shaped blotches (or a cloudy fade). 동일한 alias를 가진 컴포넌트가 존재하는 경우, 새 컴포넌트의 전환이 완료되면 기존 컴포넌트가 제거됩니다.
- When removing a component, it disappears in noise-shaped blotches and is then removed.
The transitions.noiseDissolveIn function displays a canvas element with a noise-dissolve-in transition.
The transitions.noiseDissolveOut function removes a canvas element with a noise-dissolve-out transition.
import { newLabel, transitions } from "@drincs/pixi-vn";
export const startLabel = newLabel("start", [
async () => {
await transitions.noiseDissolveIn("alien", "egg_head");
await transitions.noiseDissolveIn("human", {
value: ["m01-body", "m01-eyes", "m01-mouth"],
options: { scale: 0.5, xAlign: 0.7 },
});
},
async () => {
await transitions.noiseDissolveIn("alien", "flower_top", { edge: "soft", noiseScale: 4 });
transitions.noiseDissolveOut("human");
},
]);This animation was introduced in version v1.9.5.
The TV in/out transition mimics an old CRT television turning on or off: a bright dot stretches into a glowing horizontal line, which then opens up into the full image (with scanlines), or the reverse when removing. The scale animates around the component's own anchor/pivot, so a centered anchor looks best.
- When showing a component, it opens up from a glowing line into the full image.
- When removing a component, it collapses into a glowing line, then a dot, and is removed.
The transitions.tvIn function displays a canvas element with a TV-in transition.
The transitions.tvOut function removes a canvas element with a TV-out transition.
import { newLabel, transitions } from "@drincs/pixi-vn";
export const startLabel = newLabel("start", [
async () => {
await transitions.tvIn("alien", "egg_head");
await transitions.tvIn("human", {
value: ["m01-body", "m01-eyes", "m01-mouth"],
options: { scale: 0.5, xAlign: 0.7 },
});
},
async () => {
await transitions.tvIn("alien", "flower_top", { brightness: 4, scanlines: true });
transitions.tvOut("human");
},
]);This animation was introduced in version v1.9.5.
The pinch in/out transition makes a component emerge from (or collapse into) a single point, deforming outward as it settles, or puffing outward with mode: "bulge".
- When showing a component, it emerges from a single point, deforming outward as it settles (or puffs out of it with
mode: "bulge"). 동일한 alias를 가진 컴포넌트가 존재하는 경우, 새 컴포넌트의 전환이 완료되면 기존 컴포넌트가 제거됩니다. - When removing a component, it is sucked into a single point (or puffs out with
mode: "bulge") and removed.
The transitions.pinchIn function displays a canvas element with a pinch-in transition.
The transitions.pinchOut function removes a canvas element with a pinch-out transition.
import { newLabel, transitions } from "@drincs/pixi-vn";
export const startLabel = newLabel("start", [
async () => {
await transitions.pinchIn("alien", "egg_head");
await transitions.pinchIn("human", {
value: ["m01-body", "m01-eyes", "m01-mouth"],
options: { scale: 0.5, xAlign: 0.7 },
});
},
async () => {
await transitions.pinchIn("alien", "flower_top", { mode: "bulge" });
transitions.pinchOut("human");
},
]);사용자 정의 기능
Pixi’VN 팀은 이 라이브러리를 더욱 완성도 있게 만들기 위한 새로운 제안과 기여를 환영합니다. 아래 채팅에서 여러분의 전환을 자유롭게 공유하거나 제안해 주세요!
나만의 전환을 만드는 것은 간단합니다. canvas.animate를 사용하여 커스텀 효과를 정의하세요.
To help you get started, here is a simplified version of transitions.showWithDissolve:
import { canvas, ImageSprite, UPDATE_PRIORITY } from "@drincs/pixi-vn";
import { AnimationOptions } from "@drincs/pixi-vn/motion";
export default async function showWithDissolve(
alias: string,
component: ImageSprite,
props: AnimationOptions = {},
priority?: UPDATE_PRIORITY,
): Promise<string[] | undefined> {
let { completeOnContinue = true, ...options } = props;
// add the new component
canvas.add(alias, component);
// edit the properties of the new component
component.alpha = 0;
// create the ticker and play it
let id = canvas.animate(
alias,
{
alpha: 1,
},
{
...options,
completeOnContinue,
},
priority,
);
// load the image if the image is not loaded
if (component.haveEmptyTexture) {
await component.load();
}
// return the ids of the tickers
if (id) {
return [id];
}
}canvas.animate (above) animates a canvas component's own properties - alpha, position, scale, and
so on. Some effects (blur, pixelate, glow, color grading, ...) instead need to animate a PixiJS
Filter's own properties over time - that's
what filters.animate (from @drincs/pixi-vn/filters) is for. This functionality is available
starting from v1.9.4. It's the same mechanism transitions.blurIn/blurOut/pixelateIn/pixelateOut
use internally.
filters.animate mirrors canvas.animate's (alias, keyframes, options, priority) shape, with the
Filter instance to animate inserted as the second argument. You're responsible for attaching the
filter to the component before starting the animation, and detaching (and destroying) it once the
animation completes, via the cleanup callback:
import { canvas, ImageSprite, UPDATE_PRIORITY } from "@drincs/pixi-vn";
import { filters } from "@drincs/pixi-vn/filters";
import { AnimationOptions } from "@drincs/pixi-vn/motion";
export default async function blurIn(
alias: string,
component: ImageSprite,
props: AnimationOptions & { strength?: number } = {},
priority?: UPDATE_PRIORITY,
): Promise<string[] | undefined> {
let { strength = 32, completeOnContinue = true, ...options } = props;
// add the new component
canvas.add(alias, component);
// create the filter and attach it to the component
const filter = new filters.BlurFilter({ strength });
component.filters = [filter];
// animate the filter's own `strength` property down to 0
let id = filters.animate(
alias,
filter,
{
strength: [strength, 0],
},
{
...options,
completeOnContinue,
},
priority,
undefined,
// cleanup: runs once the animation completes - detach and destroy the filter
() => {
component.filters = null;
filter.destroy();
},
);
// load the image if the image is not loaded
if (component.haveEmptyTexture) {
await component.load();
}
// return the ids of the tickers
if (id) {
return [id];
}
}filters.animate can also drive a plain numeric progress value instead of a Filter's own property -
pass undefined as the filter and an apply callback (called every frame with the interpolated
value) in its place. This is how transitions.wipeIn/irisIn/splitIn animate their mask geometry
(a growing radius, a moving boundary, ...), since a mask has no filter property to write directly.
The Filters page covers every filter Pixi’VN registers out of the box, plus how to make a custom filter save-compatible.
이전 컴포넌트 교체 또는 제거
동일한 alias를 가진 컴포넌트가 이미 존재하는 경우, 이를 교체되도록 두거나 다음과 같이 할 수 있습니다:
새 컴포넌트의 전환이 완료되었을 때 이전 컴포넌트를 제거하려면 aliasToRemoveAfter 속성을 사용하세요.
import { canvas, ImageSprite, tickers, UPDATE_PRIORITY } from "@drincs/pixi-vn";
import { AnimationOptions } from "@drincs/pixi-vn/motion";
export default async function showWithDissolve(
alias: string,
component: ImageSprite,
props: AnimationOptions = {},
priority?: UPDATE_PRIORITY,
): Promise<string[] | undefined> {
let { completeOnContinue = true, ...options } = props;
// check if the alias is already exist
let oldComponentAlias: string | undefined = undefined;
let oldComponent = canvas.find(alias);
if (oldComponent) {
oldComponentAlias = alias + "_temp_disolve";
canvas.editAlias(alias, oldComponentAlias);
}
// add the new component and transfer the properties of the old component to the new component
canvas.add(alias, component);
oldComponent?.parent?.setChildIndex(
oldComponent,
oldComponent.parent.getChildIndex(oldComponent) - 0.1,
);
oldComponentAlias &&
canvas.copyCanvasElementProperty(oldComponentAlias, alias);
oldComponentAlias &&
tickers.transfer(oldComponentAlias, alias, "duplicate");
// edit the properties of the new component
component.alpha = 0;
// create the ticker and play it
let id = canvas.animate(
alias,
{
alpha: 1,
},
{
...options,
completeOnContinue,
},
priority,
);
// load the image if the image is not loaded
if (component.haveEmptyTexture) {
await component.load();
}
// return the ids of the tickers
if (id) {
return [id];
}
}전환과 함께 이전 컴포넌트를 제거하려면 canvas.animate로 또 다른 애니메이션을 실행하고 tickerIdToResume 속성을 사용하세요.
import { canvas, ImageSprite, tickers, UPDATE_PRIORITY } from "@drincs/pixi-vn";
import { AnimationOptions } from "@drincs/pixi-vn/motion";
export default async function showWithDissolve(
alias: string,
component: ImageSprite,
props: AnimationOptions = {},
priority?: UPDATE_PRIORITY,
): Promise<string[] | undefined> {
let { completeOnContinue = true, ...options } = props;
// check if the alias is already exist
let oldComponentAlias: string | undefined = undefined;
let oldComponent = canvas.find(alias);
if (oldComponent) {
return showWithDissolve(alias, component, props, priority);
}
let oldComponentAlias = alias + "_temp_fade";
canvas.editAlias(alias, oldComponentAlias);
// add the new component and transfer the properties of the old component to the new component
canvas.add(alias, component);
oldComponent?.parent?.setChildIndex(
oldComponent,
oldComponent.parent.getChildIndex(oldComponent) - 0.1,
);
oldComponentAlias &&
canvas.copyCanvasElementProperty(oldComponentAlias, alias);
oldComponentAlias &&
tickers.transfer(oldComponentAlias, alias, "duplicate");
// edit the properties of the new component
component.alpha = 0;
// create the ticker and play it
let id = canvas.animate(
alias,
{
alpha: 1,
},
{
...options,
completeOnContinue,
},
priority,
);
if (id) {
// pause the ticker
tickers.pause({ id: id });
// remove the old component
canvas.animate(
alias,
{
alpha: 0,
},
{
...options,
tickerIdToResume: id,
aliasToRemoveAfter: oldComponentAlias,
completeOnContinue,
},
priority,
);
}
// load the image if the image is not loaded
if (component.haveEmptyTexture) {
await component.load();
}
// return the ids of the tickers
if (id) {
return [id];
}
}