Class TextDisplay
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.rendering.RenderComponent
com.csse3200.game.ui.UIComponent
com.csse3200.game.components.maingame.TextDisplay
- All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable
,Renderable
,Comparable<Renderable>
The UIComponent to create textbox which are drawn to the bottom of the screen
-
Field Summary
FieldsModifier and TypeFieldDescriptioncom.badlogic.gdx.scenes.scene2d.ui.Label
Fields inherited from class com.csse3200.game.ui.UIComponent
skin, stage
-
Constructor Summary
ConstructorsConstructorDescriptionTextDisplay
(com.badlogic.gdx.ScreenAdapter game) TextDisplay
(com.badlogic.gdx.ScreenAdapter game, String screen) -
Method Summary
Modifier and TypeMethodDescriptionvoid
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 eventsvoid
draw
(com.badlogic.gdx.graphics.g2d.SpriteBatch batch) Overrides the draw method from the Actor class.long
getDelay()
Gets the delay of each character printing on the screencom.badlogic.gdx.scenes.scene2d.ui.Table
getTable()
Returns the table layout for the UI component.getText()
Gets the text in the blocks allocated by the algorithmboolean
Gets the visibility of the textbox on the screenvoid
Sets the current screen for this component.void
setStage
(com.badlogic.gdx.scenes.scene2d.Stage stage) Sets the stage for this UI component.void
Sets the text in allocated blocks based on text limitvoid
setVisible
(boolean value) Set visibility of the textboxvoid
update()
This function will add text after a certain amount of time given the delay constantMethods inherited from class com.csse3200.game.ui.UIComponent
getLayer, getZIndex
Methods inherited from class com.csse3200.game.rendering.RenderComponent
compareTo, dispose, render
Methods inherited from class com.csse3200.game.components.Component
earlyUpdate, getEntity, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Comparable
compareTo
Methods inherited from interface com.csse3200.game.rendering.Renderable
render
-
Field Details
-
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
-
-
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 classUIComponent
-
setText
Sets the text in allocated blocks based on text limit- Parameters:
text
- - a string which is the text to be displayed
-
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 -
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 classRenderComponent
- 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
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.
-