Skip to Content
Pixi’VN

Spine 2D

How to use the Spine 2D integration in Pixi’VN to load skeletons, switch skins, play and combine animations, and control animation tracks.

Within your Pixi’VN project, you can use the Spine 2D integration to create complex and smooth animations for your characters and objects. This integration is essentially a wrapper around the official Spine 2D runtime for PixiJS, allowing you to use all Spine 2D features directly inside your Pixi’VN project.

Installation

To add Spine 2D to an existing Pixi’VN template (created with create-pixi-vn), run the following command in the project folder:

npm create pixi-vn@latest add spine2d

It adds the dependency to package.json and sets up main.ts, vite.config.ts and (for ink templates) the hashtag commands. If the changes cannot be applied cleanly, the project is left untouched.

Usage

You can use the Spine component just like any other Pixi’VN component. However, you must first load the Spine 2D assets (skeleton and atlas) before using it.

For example:

main.ts
import { Assets, canvas } from "@drincs/pixi-vn";
import { Spine } from "@drincs/pixi-vn-spine";

await Assets.load(["spineboySkeleton", "spineboyAtlas"]);
const spine = new Spine({
    atlas: "spineboyAtlas",
    skeleton: "spineboySkeleton",
    xAlign: 0.5,
    yAlign: 1,
    animation: "idle",
});
canvas.add("boy", spine);

On this page