chore(button): update button implementation
This commit is contained in:
@ -88,7 +88,7 @@ public class Assets {
|
|||||||
// Load all assets here
|
// Load all assets here
|
||||||
assetManager.load("textures/main_menu/background.png", Texture.class);
|
assetManager.load("textures/main_menu/background.png", Texture.class);
|
||||||
assetManager.load("textures/main_menu/title.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() {
|
public static boolean isLoadedAll() {
|
||||||
|
|||||||
@ -2,9 +2,6 @@ package org.vibecoders.moongazer.scenes;
|
|||||||
|
|
||||||
import static org.vibecoders.moongazer.Constants.*;
|
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.managers.Assets;
|
||||||
import org.vibecoders.moongazer.ui.UITextButton;
|
import org.vibecoders.moongazer.ui.UITextButton;
|
||||||
import org.vibecoders.moongazer.Game;
|
import org.vibecoders.moongazer.Game;
|
||||||
|
|||||||
@ -11,29 +11,22 @@ import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
|
|||||||
|
|
||||||
public class UITextButton extends UIButton {
|
public class UITextButton extends UIButton {
|
||||||
private Texture buttonTexture;
|
private Texture buttonTexture;
|
||||||
private Texture buttonDownTexture;
|
|
||||||
private Texture buttonOverTexture;
|
|
||||||
|
|
||||||
public UITextButton(String text, BitmapFont font) {
|
public UITextButton(String text, BitmapFont font) {
|
||||||
buttonTexture = Assets.getAsset("textures/ui/menu_button.png", Texture.class);
|
buttonTexture = Assets.getAsset("textures/ui/text_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);
|
|
||||||
TextureRegionDrawable buttonDrawable = new TextureRegionDrawable(new TextureRegion(buttonTexture));
|
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();
|
TextButton.TextButtonStyle style = new TextButton.TextButtonStyle();
|
||||||
// Text style
|
|
||||||
style.font = font;
|
style.font = font;
|
||||||
style.fontColor = Color.BLACK;
|
style.fontColor = Color.BLACK;
|
||||||
style.overFontColor = Color.BLACK;
|
style.overFontColor = Color.BLACK;
|
||||||
style.downFontColor = Color.BLACK;
|
style.downFontColor = Color.BLACK;
|
||||||
// Button style
|
|
||||||
style.up = buttonDrawable;
|
style.up = buttonDrawable.tint(new Color(0.9f, 0.9f, 0.9f, 1f));
|
||||||
style.down = buttonDownDrawable;
|
style.down = buttonDrawable.tint(new Color(0.8f, 0.8f, 0.8f, 1f));
|
||||||
style.over = buttonOverDrawable;
|
style.over = buttonDrawable.tint(new Color(1f, 1f, 1f, 1f));
|
||||||
|
|
||||||
this.button = new TextButton(text, style);
|
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 |
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
Reference in New Issue
Block a user