-
Notifications
You must be signed in to change notification settings - Fork 4
MainMenuScreen
The MainMenuScreen class in the game is responsible for rendering the main menu and utilizes various sprite sheets for creating animations and visuals for celestial objects like stars, galaxies, and planets.
The main menu screen features a background image that sets the ambiance for the game's main menu. The background image, named "main_menu_bg.png
" plays a vital role in immersing players in the game's universe.
public MainMenuScreen(GdxGame game) {
this.game = game;
// Initialize and load assets including sprite sheets
loadAssets(); // Loads sprite sheets and the main menu background image
createUI();
}
// ... (Previous code)
// Load the main menu background image
backgroundTexture = new Texture("images/background/main_menu/main_menu_bg.png");
// ... (Previous code)
// Render the background image
batch.begin();
batch.draw(backgroundTexture, 0, 0, screenWidth, screenHeight);
batch.end();
// ... (Previous code)
- Location: images/background/main_menu/MM_Objects/MM_Star1.png
- Total Frames: 60
- Frame Dimensions: Variable
- Animation Speed: 0.17 seconds per frame
This sprite sheet is used to create the animation for the "MM_Star1
" celestial object in the main menu. It contains 60 frames that are used to animate the object, with an animation speed of 0.17 seconds per frame.
- Location: images/background/main_menu/MM_Objects/MM_Galaxy1.png
- Total Frames: 60
- Frame Dimensions: Variable
- Animation Speed: 0.17 seconds per frame
The "MM_Galaxy1
" sprite sheet is used to create the animation for a celestial galaxy object in the main menu. It consists of 60 frames, and each frame represents a different state of the galaxy. The animation speed is set to 0.17 seconds per frame.
- Location: images/background/main_menu/MM_Objects/MM_Planet1.png
- Total Frames: 60
- Frame Dimensions: Variable
- Animation Speed: 0.17 seconds per frame
This sprite sheet is used to create the animation for the "MM_Planet1
" celestial object in the main menu. It includes 60 frames that are used to animate the object, with an animation speed of 0.17 seconds per frame.
- Location: images/background/main_menu/MM_Objects/MM_Planet2.png
- Total Frames: 60
- Frame Dimensions: Variable
- Animation Speed: 0.17 seconds per frame
The "MM_Planet2
" sprite sheet is used to create the animation for another celestial planet object in the main menu. It comprises 60 frames, with each frame representing a different state of the planet. The animation speed is set to 0.17 seconds per frame.
- Location: images/background/main_menu/MM_Objects/MM_Planet3.png
- Total Frames: 54
- Frame Dimensions: Variable
- Animation Speed: 0.17 seconds per frame
This sprite sheet is used to create the animation for the "MM_Planet3
" celestial object in the main menu. It contains 54 frames used for the animation, with an animation speed of 0.17 seconds per frame.
These sprite sheets play a crucial role in creating the visual elements and animations within the main menu of the game.
The MainMenuScreen class initializes and loads assets, including textures and sprite sheets, to create an animated background with celestial objects. The loadAssets method is responsible for this initialization.
// ... (Previous code)
// Initialize sprite animations and other variables
private Animation<TextureRegion> MM_Star1_animation;
private Animation<TextureRegion> MM_Galaxy1_animation;
private Animation<TextureRegion> MM_Planet1_animation;
private Animation<TextureRegion> MM_Planet2_animation;
private Animation<TextureRegion> MM_Planet3_animation;
// ... (Previous code)
public MainMenuScreen(GdxGame game) {
this.game = game;
// Initialize and load assets including sprite sheets
loadAssets();
createUI();
}
The "render
" method is responsible for rendering the main menu screen. It clears the screen, updates entities, and renders the background and animated celestial objects.
`@Override`
`public void render(float delta) {`
`Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);`
`ServiceLocator.getEntityService().update();`
`// ... (Rendering the background)`
`renderer.render();`
`batch.begin();`
`elapsedTime += delta;`
`// Render animated celestial objects (stars, galaxies, and planets)`
`// ... (Logic for rendering MM_Star1, MM_Galaxy1, MM_Planet1, MM_Planet2, MM_Planet3)`
`batch.end();`
`}`
The "loadAssets
" method initializes and loads assets for the main menu screen, including textures and animations for celestial objects such as stars, galaxies, and planets. Each sprite sheet is divided into individual frames for animation purposes.
`private void loadAssets() {`
`logger.debug("Loading assets");`
`ResourceService resourceService = ServiceLocator.getResourceService();`
`resourceService.loadTextures(mainMenuTextures);`
`backgroundTexture = new Texture("images/background/main_menu/main_menu_bg.png");`
`// Loading sprite sheet frames for celestial objects`
`// ... (Logic for loading MM_Star1, MM_Galaxy1, MM_Planet1, MM_Planet2, MM_Planet3)`
`ServiceLocator.getResourceService().loadAll();`
`}`
The "unloadAssets
" method unloads assets that were previously loaded for the main menu screen. It disposes of textures and sprite sheets used for celestial objects.
`private void unloadAssets() {`
`logger.debug("Unloading assets");`
`ResourceService resourceService = ServiceLocator.getResourceService();`
`resourceService.unloadAssets(mainMenuTextures);`
`MM_Star1_Texture.dispose();`
`MM_Galaxy1_Texture.dispose();`
`MM_Planet1_Texture.dispose();`
`MM_Planet2_Texture.dispose();`
`MM_Planet3_Texture.dispose();`
`}`
In the testing phase, we initially attempted to simulate various scenarios through general mocking by creating a test file. However, it became evident that this approach was not feasible. Consequently, we shifted to a more visual approach. This testing method involved a series of actions, such as adjusting the screen resolution from the settings menu, and repeatedly minimizing and maximizing the screen. The primary goal was to verify the consistency of the sprites with both the background image and the background image in relation to changes in screen size.