Skip to content

getting started

Black Ram edited this page Nov 12, 2024 · 35 revisions

Getting Started

You can start using Pixi’VN by initializing a new project or installing the package in an existing project.

Prerequisites

Project Initialization

To initialize a new project, you can use the following command:

:::tabs == npm

npm create pixi-vn@latest

== yarn

yarn create pixi-vn@latest

== pnpm

pnpm create pixi-vn@latest

== bun

bun create pixi-vn@latest

:::

The supported template presets are:

( More templates will be added in the future, see this issue for more information )

After the project is initialized, you can open the project directory with your text editor (VSCode is recommended) and start developing your visual novel.

Into all templates there is a README.md file with more information about the project.

Package Installation

For installing the Pixi’VN package, you can use the following command:

:::tabs == npm

npm install @drincs/pixi-vn

== yarn

yarn add @drincs/pixi-vn

== pnpm

pnpm add @drincs/pixi-vn

== bun

bun add @drincs/pixi-vn

:::

Now you must initialize the Pixi’VN window before using the engine.

For example, you add the following code to the main.ts or index.ts (It depends on your project configuration):

import { canvas, narration, clearAllGameDatas } from '@drincs/pixi-vn'
import App from './App'
import './index.css'

// Canvas setup with PIXI
const body = document.body
if (!body) {
    throw new Error('body element not found')
}

canvas.initialize(body, 1920, 1080, {
    backgroundColor: "#303030"
})

// read more here: https://pixi-vn.web.app/start/labels.html#how-manage-the-end-of-the-game
narration.onGameEnd = async (props) => {
    clearAllGameDatas()
    props.navigate("/")
}

How enable the decorators in TypeScript?

In Pixi’VN, in some advanced features, it is necessary to use decorators.

By default, TypeScript does not enable the use of decorators. To enable the use of decorators in TypeScript, you must add the following configuration to the tsconfig.json file:

{
    "compilerOptions": {
        // ...
        "experimentalDecorators": true
    }
}
Clone this wiki locally