Skip to content

Commit

Permalink
Main Menu Screen - Added title, fixed resizing issue & reduce redundancy
Browse files Browse the repository at this point in the history
  • Loading branch information
aadityayadav17 committed Oct 13, 2023
1 parent bcc94d0 commit f5dc0a6
Show file tree
Hide file tree
Showing 4 changed files with 138 additions and 176 deletions.
Binary file modified source/core/assets/images/background/main_menu/main_menu_bg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,13 @@ private void addActors() {
cursorPixmap.dispose(); // Dispose of the Pixmap to release resources

table = new Table();
table1 = new Table();
table.setFillParent(true);
table1.setFillParent(true);
stage.addActor(table);

Image title =
new Image(
ServiceLocator.getResourceService()
.getAsset("images/background/main_menu/main_menu_bg.png", Texture.class));
Texture backgroundTexture = ServiceLocator.getResourceService().getAsset("images/background/main_menu/main_menu_bg.png", Texture.class);
Image title = new Image(backgroundTexture);
title.setFillParent(true);
table.addActorAt(0, title);
title.setWidth(Gdx.graphics.getWidth());
title.setHeight(Gdx.graphics.getHeight());
title.setPosition(0, 0);
Expand Down Expand Up @@ -130,18 +129,13 @@ public void changed(ChangeEvent changeEvent, Actor actor) {
float padTopOtherBtns = 15f / originalScreenHeight * Gdx.graphics.getHeight();


table.add(title);
table1.row();
table1.add(startBtn).padTop(padTopStartBtn);
table1.row();
table1.add(helpBtn).padTop(padTopOtherBtns);
table1.row();
table1.add(settingsBtn).padTop(padTopOtherBtns);
table1.row();
table1.add(exitBtn).padTop(padTopOtherBtns);
table.center();
table.add(startBtn).padTop(250f).center().row();
table.add(helpBtn).padTop(15f).center().row();
table.add(settingsBtn).padTop(15f).center().row();
table.add(exitBtn).padTop(15f).center().row();

stage.addActor(table);
stage.addActor(table1);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* Represents a pair of animation and texture for rendering in a game screen.
* Provides easy access to the animation and its associated texture.
*
* @param <TextureRegion> The type of texture region used in the animation.
*/
package com.csse3200.game.screens;

import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Animation;
import com.badlogic.gdx.graphics.g2d.TextureRegion;

public class AnimationTexturePair {
public final Animation<TextureRegion> animation;
public final Texture texture;

/**
* Creates an {@code AnimationTexturePair} with the specified animation and texture.
*
* @param animation The animation to be associated with this pair.
* @param texture The texture to be associated with this pair.
*/
public AnimationTexturePair(Animation<TextureRegion> animation, Texture texture) {
this.animation = animation;
this.texture = texture;
}

/**
* Gets the animation associated with this pair.
*
* @return The animation.
*/
public Animation<TextureRegion> getAnimation() {
return animation;
}

/**
* Gets the texture associated with this pair.
*
* @return The texture.
*/
public Texture getTexture() {
return texture;
}
}
Loading

0 comments on commit f5dc0a6

Please sign in to comment.