関節アニメーション
関節アニメーション(canvas.animate を基に構築され、Pixi’VN のキャンバスコンポーネントで揺れなどの複雑なエフェクトを作成するための関数)の使い方を学びます。
関節アニメーションとは、canvas.animate 関数を使用して、キャンバスコンポーネントに適用できるアニメーションを作成する関数です。これらの関数は通常、揺れやバウンドなど、複数のステップやコンポーネントを含む複雑なアニメーション効果を作成するために使用されます。
The effects.shakeEffect function is an articulated animation that shakes a component.
import {
CANVAS_APP_GAME_LAYER_ALIAS,
effects,
newLabel,
showImage,
} from "@drincs/pixi-vn";
export const startLabel = newLabel("start", [
async () => {
await showImage("bg", "bg", { scale: 1.3 });
await showImage("alien", "alien", { align: 0.5 });
effects.shakeEffect("alien");
},
async () => {
effects.shakeEffect(CANVAS_APP_GAME_LAYER_ALIAS);
},
]);This animation was introduced in version v1.9.5.
The effects.bounceEffect function displaces a component towards a direction and back, decaying over a number of bounces - like it's hopping on the spot.
import { effects, newLabel, showImage } from "@drincs/pixi-vn";
export const startLabel = newLabel("start", [
async () => {
await showImage("alien", "alien", { align: 0.5 });
await effects.bounceEffect("alien");
},
async () => {
await effects.bounceEffect("alien", { direction: "left", distance: 50, bounces: 4 });
},
]);This animation was introduced in version v1.9.5.
The effects.pulseEffect function scales a component up and back down to its original size, decaying over a number of pulses - a "heartbeat" style emphasis.
import { effects, newLabel, showImage } from "@drincs/pixi-vn";
export const startLabel = newLabel("start", [
async () => {
await showImage("alien", "alien", { align: 0.5 });
await effects.pulseEffect("alien");
},
async () => {
await effects.pulseEffect("alien", { pulses: 1, scale: 1.5 });
},
]);This animation was introduced in version v1.9.5.
The effects.hopEffect function performs a single primary hop towards a direction, optionally followed by smaller decaying secondary hops.
import { effects, newLabel, showImage } from "@drincs/pixi-vn";
export const startLabel = newLabel("start", [
async () => {
await showImage("alien", "alien", { align: 0.5 });
await effects.hopEffect("alien");
},
async () => {
await effects.hopEffect("alien", { distance: 60, secondaryHops: 3 });
},
]);This animation was introduced in version v1.9.5.
The effects.wiggleEffect function rocks a component's rotation back and forth around its current angle, decaying over a number of repetitions.
import { effects, newLabel, showImage } from "@drincs/pixi-vn";
export const startLabel = newLabel("start", [
async () => {
await showImage("alien", "alien", { align: 0.5 });
await effects.wiggleEffect("alien");
},
async () => {
await effects.wiggleEffect("alien", { angle: 25, repetitions: 6 });
},
]);This animation was introduced in version v1.9.5.
The effects.nodEffect function oscillates a component back and forth along an axis (horizontal or vertical), decaying over a number of repetitions - like a nodding or shaking-head gesture.
import { effects, newLabel, showImage } from "@drincs/pixi-vn";
export const startLabel = newLabel("start", [
async () => {
await showImage("alien", "alien", { align: 0.5 });
await effects.nodEffect("alien");
},
async () => {
await effects.nodEffect("alien", { axis: "vertical", distance: 25 });
},
]);This animation was introduced in version v1.9.5.
The effects.swayEffect function drifts a component's position and rotation back and forth, decaying over a number of repetitions - a gentle, idle-motion sway.
import { effects, newLabel, showImage } from "@drincs/pixi-vn";
export const startLabel = newLabel("start", [
async () => {
await showImage("alien", "alien", { align: 0.5 });
await effects.swayEffect("alien");
},
async () => {
await effects.swayEffect("alien", { distance: 40, angle: 10 });
},
]);This animation was introduced in version v1.9.5.
The effects.punchEffect function is a single one-shot attack-and-recover animation (not decaying like the effects above) on a component's scale, x, y, or rotation, with an optional overshoot on the recovery.
import { effects, newLabel, showImage } from "@drincs/pixi-vn";
export const startLabel = newLabel("start", [
async () => {
await showImage("alien", "alien", { align: 0.5 });
await effects.punchEffect("alien");
},
async () => {
await effects.punchEffect("alien", { mode: "scale", strength: 0.5 });
},
]);This animation was introduced in version v1.9.5.
The effects.glitchEffect function plays one or more digital-corruption bursts (displaced slices, plus an optional RGB channel split) on a component, without removing or showing it. Works best on detailed, high-contrast images - it barely reads on flat colors.
import { effects, newLabel, showImage } from "@drincs/pixi-vn";
export const startLabel = newLabel("start", [
async () => {
await showImage("alien", "alien", { align: 0.5 });
await effects.glitchEffect("alien");
},
async () => {
await effects.glitchEffect("alien", { strength: 80, bursts: 5, rgbSplit: 12 });
},
]);This animation was introduced in version v1.9.5.
The effects.chromaticAberrationEffect function splits the red/blue channels apart and back together, decaying over a number of bursts - a lens-distortion/glitch flourish.
import { effects, newLabel, showImage } from "@drincs/pixi-vn";
export const startLabel = newLabel("start", [
async () => {
await showImage("alien", "alien", { align: 0.5 });
await effects.chromaticAberrationEffect("alien");
},
async () => {
await effects.chromaticAberrationEffect("alien", { strength: 15, bursts: 3 });
},
]);This animation was introduced in version v1.9.5.
The effects.shockwaveEffect function is a single one-shot ring of water-like distortion expanding outward from an origin point on a component.
import { effects, newLabel, showImage } from "@drincs/pixi-vn";
export const startLabel = newLabel("start", [
async () => {
await showImage("alien", "alien", { align: 0.5 });
await effects.shockwaveEffect("alien");
},
async () => {
await effects.shockwaveEffect("alien", { origin: { x: 0.5, y: 0.5 }, amplitude: 40 });
},
]);This animation was introduced in version v1.9.5.
The effects.radialBlurEffect function bursts a zoom-blur in and out from a center point on a component, decaying over a number of bursts.
import { effects, newLabel, showImage } from "@drincs/pixi-vn";
export const startLabel = newLabel("start", [
async () => {
await showImage("alien", "alien", { align: 0.5 });
await effects.radialBlurEffect("alien");
},
async () => {
await effects.radialBlurEffect("alien", { strength: 0.9, bursts: 2 });
},
]);This animation was introduced in version v1.9.5.
The effects.blurPulseEffect function pulses a component in and out of blur, decaying over a number of pulses.
import { effects, newLabel, showImage } from "@drincs/pixi-vn";
export const startLabel = newLabel("start", [
async () => {
await showImage("alien", "alien", { align: 0.5 });
await effects.blurPulseEffect("alien");
},
async () => {
await effects.blurPulseEffect("alien", { strength: 12, pulses: 3 });
},
]);This animation was introduced in version v1.9.5.
The effects.vignettePulseEffect function pulses a darkening vignette in from a component's corners and back out, decaying over a number of pulses. Needs a full-frame background/image to be visible - it darkens the element's own corners, so a character sprite with transparent margins around it won't show much.
import {
CANVAS_APP_GAME_LAYER_ALIAS,
effects,
newLabel,
showImage,
} from "@drincs/pixi-vn";
export const startLabel = newLabel("start", [
async () => {
await showImage("background", "bg_grass");
await effects.vignettePulseEffect(CANVAS_APP_GAME_LAYER_ALIAS);
},
async () => {
await effects.vignettePulseEffect(CANVAS_APP_GAME_LAYER_ALIAS, { radius: 0.7, blur: 0.6, pulses: 3 });
},
]);This animation was introduced in version v1.9.5.
The effects.desaturateEffect function is a single one-shot dip into (and recovery from) reduced saturation, with an optional hold at the trough - for a shock/fear/flashback beat.
import { effects, newLabel, showImage } from "@drincs/pixi-vn";
export const startLabel = newLabel("start", [
async () => {
await showImage("alien", "alien", { align: 0.5 });
await effects.desaturateEffect("alien");
},
async () => {
await effects.desaturateEffect("alien", { amount: 0, holdDuration: 0.5 });
},
]);This animation was introduced in version v1.9.5.
The effects.glowPulseEffect function pulses an outward glow on a component, decaying over a number of pulses - for a "power up" or magical highlight.
import { effects, newLabel, showImage } from "@drincs/pixi-vn";
export const startLabel = newLabel("start", [
async () => {
await showImage("alien", "alien", { align: 0.5 });
await effects.glowPulseEffect("alien");
},
async () => {
await effects.glowPulseEffect("alien", { color: 0x00ffff, pulses: 3 });
},
]);