Class MainGameOrderBtnDisplay
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.rendering.RenderComponent
com.csse3200.game.ui.UIComponent
com.csse3200.game.components.ordersystem.MainGameOrderBtnDisplay
- All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable
,Renderable
,Comparable<Renderable>
Displays a button on the main game screen that allows players to create a new order.
The button is positioned in the bottom right corner of the screen.
-
Field Summary
Fields inherited from class com.csse3200.game.ui.UIComponent
skin, stage
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds the button to the UI and sets up the event listener for the button click.void
create()
Initialises the button display and sets up the actors in the UI.void
dispose()
Removes the buttonvoid
draw
(com.badlogic.gdx.graphics.g2d.SpriteBatch batch) Draws the button on the screen.boolean
getState()
Get the state of the buttoncom.badlogic.gdx.scenes.scene2d.ui.Table
getTable()
float
Returns the z-index for this component.void
setStage
(com.badlogic.gdx.scenes.scene2d.Stage mock) Disposes of the button display, clearing the table and removing it from the stage.void
setState
(boolean pressed) Methods inherited from class com.csse3200.game.ui.UIComponent
getLayer
Methods inherited from class com.csse3200.game.rendering.RenderComponent
compareTo, render
Methods inherited from class com.csse3200.game.components.Component
earlyUpdate, getEntity, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate, update
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
-
Constructor Details
-
MainGameOrderBtnDisplay
public MainGameOrderBtnDisplay()
-
-
Method Details
-
create
public void create()Initialises the button display and sets up the actors in the UI.- Overrides:
create
in classUIComponent
-
getTable
public com.badlogic.gdx.scenes.scene2d.ui.Table getTable() -
addActors
public void addActors()Adds the button to the UI and sets up the event listener for the button click. When the "Create Order" button is clicked, it triggers the "createOrder" event. -
draw
public void draw(com.badlogic.gdx.graphics.g2d.SpriteBatch batch) Draws the button on the screen. The actual rendering is handled by the stage, so this method is empty.- Specified by:
draw
in classRenderComponent
- Parameters:
batch
- the sprite batch used for drawing.
-
getZIndex
public float getZIndex()Returns the z-index for this component. The z-index determines the rendering order of UI components.- Specified by:
getZIndex
in interfaceRenderable
- Overrides:
getZIndex
in classUIComponent
- Returns:
- the z-index for this component.
-
setStage
public void setStage(com.badlogic.gdx.scenes.scene2d.Stage mock) Disposes of the button display, clearing the table and removing it from the stage. -
getState
public boolean getState()Get the state of the button- Returns:
- true if button is pressed, false otherwise
-
setState
public void setState(boolean pressed) -
dispose
public void dispose()Removes the button- Specified by:
dispose
in interfacecom.badlogic.gdx.utils.Disposable
- Overrides:
dispose
in classRenderComponent
-