-
Notifications
You must be signed in to change notification settings - Fork 1
Dialogue Box
The ChatOverlay class is used to create a chat overlay in the game, allowing for quest hints and messages to be displayed to the player. This class leverages LibGDX's Scene2D UI framework to create and manage the overlay, including text labels and navigation buttons. This is triggered when the player stops near a paused friendly NPC, the buttons allowing the player to switch back and forth between the contents of the message box at their own pace.
-
Stage: The
stage
object from LibGDX's Scene2D framework where all UI elements are added and rendered. -
Skin: A
Skin
object that provides the visual style for UI components like labels and buttons. - Background Image: A customizable image used as the background for the chat overlay. It is centered and scaled according to the specified dimensions.
-
Label: A
Label
widget used to display the current hint or message. It is positioned dynamically based on the background image. - Forward and Backward Buttons: Navigation buttons that allow the player to cycle through the available hints. These buttons are styled using custom images and are positioned relative to the label and background.
void createBackgroundImage(String backgroundPath, float desiredHeight)
void createButtons(float labelX, float labelY, float newWidth)
void handleForwardButtonClick()
void handleBackwardButtonClick()
void dispose()
The ChatEntityService directly utilises the ChatOverlay class as multiple entities are sharing the class and will need to be required over multiple screens and places. A ChatOverlay is created with the specific hint you want to show broken up into parts stored as a String[].
In the ChatEntityService a String[] hint text is parsed through on its creation and to utilise the ChatOverlay all that is required is"
ChatOverlay currentOverlay = new ChatOverlay(hintText);
There are two states for a dialogue box button. The default state (left) and state when the player hovers their mouse over the button (right).
The following is the default art style for a message box.
- npc specific boxes (for future)
- Creation: Ensure the ChatOverlay is created properly with correct label texts, components and positioning.
- Navigation: Verify that the forward and backward buttons cycle through the messages as expected.
- Integration: Ensure the ChatOverlay integrates correctly with other classes like PauseTask.
- Memory Cleanup: Confirm that the dispose method correctly cleans up all resources to prevent memory leaks.