Menu Button - UQcsse3200/2023-studio-2 GitHub Wiki

Introduction

The PauseWindow class plays a crucial role in our game by providing a user-friendly and visually appealing menu button. When the player presses the pause button, this window appears, offering options to return to the game, access game controls, or exit to the main menu.

Description

Class Structure

The PauseWindow class extends LibGDX's Window class to create a customizable and visually engaging pause menu. Key features include the options to return to the game, access game controls, and exit to the main menu.

Features

  • Visual Customization: We provide a visually appealing and user-friendly design using custom textures.
  • Responsive Layout: The window adapts to different screen sizes and is positioned at the center of the screen.
  • Button Interaction: The class includes buttons to return to the game, access game controls, and exit to the main menu.
  • Input Override: It overrides user input while the pause menu is active.

Usage

Here's how the PauseWindow class is used in our game:

  1. Creation: To create a new PauseWindow, you can use the makeNewPauseWindow(Entity entity) factory method.
  2. Initialization: You specify the window's appearance by providing a background texture, and it automatically adjusts to the screen's dimensions.
  3. Button Actions: Users can click the "Return to Game," "Controls," or "Exit to Main Menu" buttons to perform their respective actions.
  4. Input Override: While the pause menu is open, the class overrides normal user input.

Methods

The class provides several methods:

  • makeNewPauseWindow(Entity entity):Factory method to create a new PauseWindow instance.
  • exitToGame(): Returns to the game and removes the pause window.
  • exitToControls(): Exits to the controls screen and removes the pause window.
  • exitToMainMenu(): Exits to the main menu screen and removes the pause window.
  • remove(): Removes the pause window popup and its buttons/label. It also stops overriding input when exiting the pause window.

Class Code

  • exitToControls():
  • exitToMainMenu():
  • makeNewPauseWindow(Entity entity)

Conclusion

In conclusion, the PauseWindow class enhances our game's user experience by providing an elegant and functional pause menu. It ensures players can smoothly return to the game, access controls, or exit to the main menu during gameplay.

Contributors