-
Notifications
You must be signed in to change notification settings - Fork 9
Navigation Component
The Navigation component in our game is responsible for managing navigation between different areas or planets. It allows players to explore the game world by interacting with various planets or locations. This wiki page provides an overview of the Navigation component and its associated classes
The Navigation component utilizes LibGDX's scene2d.ui framework to create interactive UI elements representing planets or locations.
package com.csse3200.game.areas;
// ... (import statements)
public class Navigation extends GameArea {
private final TerrainFactory terrainFactory;
private static final Logger logger = LoggerFactory.getLogger(Navigation.class);
private static final String[] NavigationTextures = {"images/box_boy_title.png"};
private final String image;
// Constructor
public Navigation(TerrainFactory terrainFactory, String image) {
this.terrainFactory = terrainFactory;
this.image = image;
}
// ... (other methods)
}
The Navigation class is the main component responsible for managing the navigation between game areas. It extends the GameArea class and includes the necessary instance variables, constructor, and methods for setting up navigation and disposing of resources.
package com.csse3200.game.components.navigation;
// ... (import statements)
public class level3 extends UIComponent {
private final String PlanetImage;
private final float x;
private final float y;
private Table table;
// Constructor
public level3(String PlanetImage, float x, float y) {
this.PlanetImage = PlanetImage;
this.x = x;
this.y = y;
}
// ... (other methods)
}
The level class is a specialized UI component used to represent level in our game. It extends UIComponent and includes the necessary instance variables, constructor, and methods for creating the UI component and handling its disposal.
To use the Navigation component and its associated classes in your game, follow these steps:
- Instantiate the Navigation class by providing a TerrainFactory and the image path for the navigation area.
- In the create method of the Navigation class, configure the UI elements representing planets or locations. Add listeners to these elements to define navigation logic when they are interacted with.
- Customize the level class or create similar components for other game levels or areas, specifying the image, coordinates, and interaction behavior.
- Incorporate the Navigation component into your game's main logic or state machine to enable navigation between different areas.
Here are code snippets for the key classes in the Navigation component: Navigation Class
// ... (import statements)
public class Navigation extends GameArea {
// ... (class definition)
// Constructor
public Navigation(TerrainFactory terrainFactory, String image) {
// ... (constructor code)
}
@Override
public void create() {
// ... (create method code)
}
// ... (other methods)
}
// ... (import statements)
public class level3 extends UIComponent {
// ... (class definition)
// Constructor
public level3(String PlanetImage, float x, float y) {
// ... (constructor code)
}
@Override
public void create() {
// ... (create method code)
}
// ... (other methods)
}
These code examples provide a starting point for understanding how to use the Navigation component and its associated classes.
Escape Earth Game
Interaction Controller and Interactable Components
Game and Entity Configuration Files
Loading Game Configuration Files