Visual Novel Dialogue
A minimal, JSON-driven dialogue plugin for Phaser 3 games with support for branching choices, typewriter effects, and simple inline formatting.
Try it for yourself
Demo
Features
- 🧾 JSON-based dialogue scripting
- 💬 Character nameplates with color tags
- 🧠 Label-based branching via
jump
- 🎭 Player choices
- ⏳ Typewriter text effect
- 🎨 Simple inline styling with
{style=value}
- 🧰 Global config for fonts, box style, and speed
- 🔌 Exposed API for
jumpTo
, pause
, and hooks
- 🔊 Inline audio triggers with
{audio=value}{/audio}
tags
Installation
npm install @robingamedev/visual-novel-dialogue
Quick Start
import VisualNovelDialogue from '@robingamedev/visual-novel-dialogue';
const dialogue = new VisualNovelDialogue(this, {
fontFamily: 'VT323',
typeSpeed: 30,
boxStyle: 'default',
autoForward: false,
});
dialogue.load(dialogueData);
dialogue.start('Start');
dialogue.onChoice = (label, text) => {
console.log(`Player chose: ${text}`);
};
dialogue.onEnd = () => {
console.log('Dialogue finished!');
};
Basic Usage
1. Create Dialogue Data
{
"settings": {
"characters": {
"alice": { "name": "Alice", "color": "#ff6b6b" },
"bob": { "name": "Bob", "color": "#4ecdc4" }
}
},
"script": {
"Start": [
"alice Hello there!",
"bob Hi Alice!",
{
"Choice": {
"continue": "Continue the conversation",
"end": "End here"
}
}
],
"continue": [
"alice Let's keep talking!",
"jump end"
],
"end": [
"bob Goodbye!",
"end"
]
}
}
2. API Methods
dialogue.start('Start');
dialogue.jumpTo('continue');
dialogue.pause();
dialogue.resume();
dialogue.nextLine();
dialogue.skipTypewriter();
dialogue.isTypewriterActive();
dialogue.isChoicesActive();
dialogue.show();
dialogue.hide();
3. Event Hooks
dialogue.onLineEnd = (line) => {
console.log('Line finished:', line);
};
dialogue.onChoice = (label, text) => {
console.log('Choice made:', label, text);
};
dialogue.onShow = (characterId, emotion) => {
showCharacter(characterId, emotion);
};
dialogue.onHide = (characterId) => {
hideCharacter(characterId);
};
dialogue.onEnd = () => {
console.log('Dialogue ended!');
};
Configuration Options
const config = {
fontFamily: 'Arial',
typeSpeed: 30,
boxStyle: 'default',
autoForward: false,
boxAnimationSpeed: 0,
boxPosition: 'bottom',
styles: {
bold: { bold: true },
red: { color: '#ff0000' }
},
audio: {
type: 'typewriter.wav',
choice: 'choice.wav'
},
debug: false
};
Documentation
License
MIT
Built for small teams, hobbyists, and story-heavy games. Perfect for visual novels, RPGs, and narrative-driven experiences.