chore(button): update button implementation

This commit is contained in:
2025-09-30 20:25:57 +07:00
6 changed files with 7 additions and 17 deletions

View File

@ -88,7 +88,7 @@ public class Assets {
// Load all assets here
assetManager.load("textures/main_menu/background.png", Texture.class);
assetManager.load("textures/main_menu/title.png", Texture.class);
assetManager.load("textures/ui/menu_button.png", Texture.class);
assetManager.load("textures/ui/text_button.png", Texture.class);
}
public static boolean isLoadedAll() {

View File

@ -2,9 +2,6 @@ package org.vibecoders.moongazer.scenes;
import static org.vibecoders.moongazer.Constants.*;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import org.vibecoders.moongazer.managers.Assets;
import org.vibecoders.moongazer.ui.UITextButton;
import org.vibecoders.moongazer.Game;

View File

@ -11,29 +11,22 @@ import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
public class UITextButton extends UIButton {
private Texture buttonTexture;
private Texture buttonDownTexture;
private Texture buttonOverTexture;
public UITextButton(String text, BitmapFont font) {
buttonTexture = Assets.getAsset("textures/ui/menu_button.png", Texture.class);
buttonDownTexture = Assets.getAsset("textures/ui/menu_button_down.png", Texture.class);
buttonOverTexture = Assets.getAsset("textures/ui/menu_button_over.png", Texture.class);
buttonTexture = Assets.getAsset("textures/ui/text_button.png", Texture.class);
TextureRegionDrawable buttonDrawable = new TextureRegionDrawable(new TextureRegion(buttonTexture));
TextureRegionDrawable buttonDownDrawable = new TextureRegionDrawable(new TextureRegion(buttonDownTexture));
TextureRegionDrawable buttonOverDrawable = new TextureRegionDrawable(new TextureRegion(buttonOverTexture));
TextButton.TextButtonStyle style = new TextButton.TextButtonStyle();
// Text style
style.font = font;
style.fontColor = Color.BLACK;
style.overFontColor = Color.BLACK;
style.downFontColor = Color.BLACK;
// Button style
style.up = buttonDrawable;
style.down = buttonDownDrawable;
style.over = buttonOverDrawable;
style.up = buttonDrawable.tint(new Color(0.9f, 0.9f, 0.9f, 1f));
style.down = buttonDrawable.tint(new Color(0.8f, 0.8f, 0.8f, 1f));
style.over = buttonDrawable.tint(new Color(1f, 1f, 1f, 1f));
this.button = new TextButton(text, style);
this.actor = button;
this.actor = this.button;
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

View File

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB