Dialogue
How to use, customize, and manage dialogue objects in Pixi’VN, including glue and UI integration.
UI screen
You can find the example of the narrative dialogue UI screen in the interface examples section.
What is dialogue? A written composition in which two or more characters are represented as conversing.
In Pixi’VN, dialogue is an object that contains information about who and what is currently being said. Its functionality can be broader, as it can also be used for other purposes, such as monologues, soliloquies, or to display a message to the player. For this reason, it is more appropriate to consider it as a text that can be linked to a character.
Set
To set the current dialogue, you can use narration.dialogue.
import { narration, newLabel } from "@drincs/pixi-vn";
import { eggHead } from "@/content/characters";
export const startLabel = newLabel("start", [
// A simple dialogue with only text, without a character
() => (narration.dialogue = "Hello, world!"),
// A dialogue with a character
() => {
narration.dialogue = {
character: eggHead,
text: "My name is ${eggHead.name}!",
};
},
// A dialogue with a character, but the character is not defined in the characters list
() => {
narration.dialogue = {
character: "Narrator",
text: "This is a narration without a character.",
};
},
]);Get
To get the current dialogue, use narration.dialogue. The return value is a DialogueInterface.
const currentDialogue: DialogueInterface = narration.dialogue;Delete
To clear the current dialogue, set narration.dialogue to undefined.
narration.dialogue = undefined;Custom class
You can customize the dialogue interface by adding additional properties to the DialogueInterface. For example, you can add a color property to change the color of the text.
To do this, "override" the DialogueInterface interface in your .d.ts file:
declare module "@drincs/pixi-vn" {
interface DialogueInterface {
color?: string;
}
}