-
Notifications
You must be signed in to change notification settings - Fork 9
Main Menu Display Screen
This document explains how to use and understand the MainMenuDisplay class, which displays the main menu of the game.
The MainMenuDisplay class is a UI component that displays the main menu of the game. It consists of various buttons that trigger different events when clicked.
To integrate the MainMenuDisplay into your game, follow these steps:
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import com.csse3200.game.ui.UIComponent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
// ... other imports ...
MainMenuDisplay mainMenu = new MainMenuDisplay();
mainMenu.create();
- Button Creation: The class creates different buttons, such as "Start," "Load," "Settings," "Exit," "Space," "Space Minigame," and "Extractor Minigame." Each button has a corresponding event that gets triggered when clicked.
- Button Listeners: The ChangeListener interface is used to add listeners to the buttons. When a button is clicked, its associated event is triggered, and a log message is generated.
- Table Layout: The UI components are added to a Table layout, which is then added to the stage for rendering.
To use the MainMenuDisplay class, follow these steps:
- Create an instance of MainMenuDisplay:
MainMenuDisplay mainMenu = new MainMenuDisplay();
mainMenu.create();
- Add the MainMenuDisplay instance to your game's stage:
stage.addActor(mainMenu.getTable());
- Make sure to handle the triggered events in your game logic:
mainMenu.getEntity().getEvents().on("space", () -> {
// Handle space button event
});
// ... other event handlers ...
The MainMenuDisplay class provides an organized way to display the main menu of your game. By following the steps outlined in this document, you can integrate and customize the main menu according to your game's requirements.
@24msingh24
Escape Earth Game
Interaction Controller and Interactable Components
Game and Entity Configuration Files
Loading Game Configuration Files