generated from UQcsse3200/game-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Dialogue
lutianyi edited this page Oct 30, 2025
·
10 revisions
The dialogue system wraps story-driven conversations in a reusable IntroDialogueComponent. When a map spawns this component, it pauses world time, shows a dimmed overlay with character portraits and names, and steps through a scripted list of DialogueEntry objects. Each entry can define text, speaker metadata, background art, and optional voice lines managed by DialogueAudioManager. Once the player finishes or skips the dialogue, the component restores the original time scale, cleans up UI resources, and runs a caller-provided callback so gameplay can continue (for example, enabling tower placement or starting enemy waves).

freecompress-GdxGame.2025-10-30.21-28-47.mp4
-
IntroDialogueComponent: Builds a Scene2D overlay, pauses gameplay, walks through scripted lines, and runs a completion callback to resume the game. -
DialogueEntry: Represents individual lines with text, portrait, sound, portrait side, dialogue background, and speaker name (all optional except text). -
DialogueConfig: Groups scripts per map and can pull player name/avatar from services to personalise dialogue. -
DialogueAudioManager: Handles dialogue audio preloading, playback, volume scaling, and cleanup so each line can provide narration or SFX.
- A game area spawns an entity with
IntroDialogueComponent, passing the script and anonCompleterunnable. - In
create(), the component preloads textures/sounds, pauses the time source, builds the overlay, and shows the first line. - Pressing anywhere on the overlay or the “continue” button advances the script; each step updates UI, portrait, background, and audio.
- When the script finishes or the user hits “skip”, the component tears down the overlay, restores the original time scale, fires the completion callback, and disposes itself.
- The overlay is a dimmed full-screen table with a dialogue card anchored at the bottom, optional portrait anchored left/right, and a speaker name plaque.
- “Continue” and “skip” buttons use
UIStyleHelperstyles (images/continue.png,images/skip.png) and resolution-aware fonts. - Each line can switch backgrounds; special “talker” backgrounds preserve their aspect ratio while scaling to the dialogue card.
-
preloadSounds()loads the uniquesoundPaths ahead of time to prevent runtime hitching. -
playSound()respects the user’s sound volume and applies a dialogue multiplier so voice lines stand out. - Helper methods support pausing, resuming, and adjusting the multiplier globally.
-
ForestGameAreaandForestGameArea2delay UI elements (tower hotbar, hero placement) and wave spawning until the dialogue’s completion callback, ensuring the tutorial flow runs first. - Components are added via the standard
spawnEntitypipeline; no extra rendering hooks are needed.
- Global time scale is set to 0 during dialogue and restored afterward, preserving deterministic wave timing.
-
CameraZoomDragComponentdisables zoom while any dialogue is active so the player can’t pan/zoom under the overlay. - Input listeners absorb clicks on the overlay to avoid interacting with world UI beneath the dialogue.