トランジション
canvasコンポーネントの表示・削除に使用する、Pixi’VNに組み込まれたトランジション効果(ディゾルブ、フェード、ムーブ、プッシュ、ズームの各トランジションを含む)について学びます。ゲームの流れに高度なビジュアル効果を加えるために、独自のトランジションをカスタマイズまたは作成する方法を学びます。
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");
},
]);ズームイン/アウトトランジション:
- コンポーネントを表示する際、0(canvasの外部)から元のスケールと位置までスケーリングします。同じ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];
}
}