Skip to main content

Dialog Box

The dialog box system in RPG.js allows you to display text messages and choices to players. It provides a built-in GUI component that handles text display, typewriter effects, and choice selection.

Basic Usage

Show Text

The showText() method displays a simple text message to the player:

Show Choices

The showChoices() method displays a dialog with multiple choices for the player to select from:

Dialog Options

Both showText() and showChoices() accept an options object with the following properties:

Position

Controls where the dialog box appears on screen:

Full Width

Determines if the dialog box takes the full width of the screen:

Auto Close

If enabled, the dialog automatically closes after a delay:

Typewriter Effect

Controls the typewriter animation effect:

Talk With

Makes an event or player turn toward the player during the dialog:

Speaker Name

Overrides the speaker label shown in the dialog:

Face Display

Shows a character face with a specific expression:

Faceset Configuration

To use faces in dialogs, you need to configure the faceset spritesheet on the client side. The faceset is a single image containing multiple character expressions arranged in a grid.

Client-side Setup

In your client configuration (config.client.ts), add the faceset spritesheet:

Faceset Parameters

  • id: Unique identifier for the faceset
  • image: Path to the faceset image file
  • width/height: Dimensions of the faceset image
  • framesWidth/framesHeight: Number of frames horizontally and vertically in the grid
  • expressions: Object mapping expression names to their grid positions [frameX, frameY]

Using Faces in Dialogs

Once configured, you can use the faceset in dialogs:

Faceset Image Layout

Your faceset image should be organized in a grid. For example, with framesWidth: 3 and framesHeight: 4:
Each position [frameX, frameY] corresponds to a specific expression in your faceset.

Dialog Box Customization

You can customize the appearance and sounds of the dialog box using provideClientGlobalConfig() in your client configuration.

Styling the Dialog Box

Customizing Sounds

You can customize the sounds used by the dialog box. The sound IDs in provideClientGlobalConfig() must correspond to the sound IDs defined in provideClientModules().
See also: Sounds Guide for comprehensive information about sound configuration, dynamic sound resolution, and playing sounds from the server.
Important: The sound IDs in the box.sounds configuration must match the sound IDs defined in your provideClientModules() configuration. The sounds themselves are loaded through the sounds array in provideClientModules().

Complete Configuration Example

See Also

  • Sounds Guide - Comprehensive guide on configuring and using sounds, including dynamic sound resolution
  • Prebuilt GUI Contracts - Data and interaction contract for replacing rpg-dialog with your own CanvasEngine or Vue dialog box