Class Button


  • public class Button
    extends Entity
    Represents a UI Button.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private com.badlogic.gdx.graphics.Texture activeTexture
      The texture to use when the button is being hovered over.
    • Constructor Summary

      Constructors 
      Constructor Description
      Button​(com.badlogic.gdx.math.Vector2 pos, java.lang.String activeTexture, java.lang.String inactiveTexture)
      Create a new button at a position with an inactive texture and an active texture.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean isHovering()
      If the mouse is hovering over the button.
      void render​(com.badlogic.gdx.graphics.g2d.SpriteBatch batch)
      Render the button on the screen.
      • Methods inherited from class java.lang.Object

        clone, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • activeTexture

        private final com.badlogic.gdx.graphics.Texture activeTexture
        The texture to use when the button is being hovered over.
    • Constructor Detail

      • Button

        public Button​(com.badlogic.gdx.math.Vector2 pos,
                      java.lang.String activeTexture,
                      java.lang.String inactiveTexture)
        Create a new button at a position with an inactive texture and an active texture.
        Parameters:
        pos - The position of the button on-screen.
        inactiveTexture - The texture of the button when not hovered over.
        activeTexture - The texture of the button when it is hovered over.
    • Method Detail

      • render

        public void render​(com.badlogic.gdx.graphics.g2d.SpriteBatch batch)
        Render the button on the screen.
        Overrides:
        render in class Entity
        Parameters:
        batch - The SpriteBatch to be added to.
      • isHovering

        public boolean isHovering()
        If the mouse is hovering over the button.
        Returns:
        A boolean of if the mouse is hovering over the button.