Package engine.guis
Class UiButton
java.lang.Object
engine.guis.UiComponent
engine.guis.UiButton
Button component which extends UIComponent.
Button is a 2d clickable object on screen for the user to interact with the game.
-
Field Summary
Fields inherited from class engine.guis.UiComponent
isClickable, position, scale, texture
-
Constructor Summary
ConstructorsConstructorDescriptionUiButton
(int texture, org.joml.Vector2f position, org.joml.Vector2f scale, ButtonEnum buttonEnum) Constructor for the button. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Checks if the mouse is within the position of the button.boolean
void
setEnabled
(boolean enabled) Methods inherited from class engine.guis.UiComponent
getPosition, getScale, getTexture
-
Constructor Details
-
UiButton
public UiButton(int texture, org.joml.Vector2f position, org.joml.Vector2f scale, ButtonEnum buttonEnum) Constructor for the button.- Parameters:
texture
- Texture ID of the button.position
- Position on screen as a Vector2f - center point of the object.scale
- Scale in X and Y from Centre point as Vector2fbuttonEnum
- Type of the button - used for distinction when the button is pressed.
-
-
Method Details
-
getButtonEnum
- Returns:
- Enum of the button type.
-
setEnabled
public void setEnabled(boolean enabled) - Parameters:
enabled
-
-
isEnabled
public boolean isEnabled()- Returns:
- if button is enabled
-
isClicked
public boolean isClicked()Checks if the mouse is within the position of the button. If mouse is and method is called - returns true.- Returns:
- boolean value
-