Class TextDisplay

All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable, Renderable, Comparable<Renderable>

public class TextDisplay extends UIComponent
The UIComponent to create textbox which are drawn to the bottom of the screen
  • Field Details

    • currentText

      public StringBuilder currentText
    • label

      public com.badlogic.gdx.scenes.scene2d.ui.Label label
  • Constructor Details

    • TextDisplay

      public TextDisplay()
    • TextDisplay

      public TextDisplay(com.badlogic.gdx.ScreenAdapter game)
    • TextDisplay

      public TextDisplay(com.badlogic.gdx.ScreenAdapter game, String screen)
  • Method Details

    • getDelay

      public long getDelay()
      Gets the delay of each character printing on the screen
      Returns:
      a long
    • create

      public void create()
      This function will - create a table where the UI components will be placed on - render the textbox and stack text on top using the stack - position the table in the correct place - add key input listeners and events
      Overrides:
      create in class UIComponent
    • setText

      public void setText(String text)
      Sets the text in allocated blocks based on text limit
      Parameters:
      text - - a string which is the text to be displayed
    • getText

      public List<String> getText()
      Gets the text in the blocks allocated by the algorithm
      Returns:
      a List of strings which is the text
    • setVisible

      public void setVisible(boolean value)
      Set visibility of the textbox
      Parameters:
      value - - True or False if the textbox is visible
    • getVisible

      public boolean getVisible()
      Gets the visibility of the textbox on the screen
      Returns:
      boolean which is the visibility of the status
    • update

      public void update()
      This function will add text after a certain amount of time given the delay constant
      Overrides:
      update in class Component
    • draw

      public void draw(com.badlogic.gdx.graphics.g2d.SpriteBatch batch)
      Overrides the draw method from the Actor class. This method is responsible for rendering the component. However, the actual drawing is handled by the stage, so no rendering logic is needed here.
      Specified by:
      draw in class RenderComponent
      Parameters:
      batch - The SpriteBatch used for drawing.
    • setStage

      public void setStage(com.badlogic.gdx.scenes.scene2d.Stage stage)
      Sets the stage for this UI component. The stage is used to manage the layout and actors (UI elements) for this component.
      Parameters:
      stage - The Stage to be set for this component.
    • getTable

      public com.badlogic.gdx.scenes.scene2d.ui.Table getTable()
      Returns the table layout for the UI component. This method is useful for accessing and modifying the table layout externally.
      Returns:
      The Table used for the UI layout.
    • setScreen

      public void setScreen(String screen)
      Sets the current screen for this component. This method allows you to assign a specific screen that the UI component belongs to.
      Parameters:
      screen - The name of the screen to be set.