Class ResourceDisplay
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.rendering.RenderComponent
com.csse3200.game.ui.UIComponent
com.csse3200.game.components.resources.ResourceDisplay
- All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable,Renderable,Comparable<Renderable>
A ui component for displaying resources in the bottom right corner of the screen.
-
Field Summary
Fields inherited from class com.csse3200.game.ui.UIComponent
skin, stage -
Constructor Summary
ConstructorsConstructorDescriptionResourceDisplay(int scale, int steps, int maxResource) Constructor for the ResourceDisplay. -
Method Summary
Modifier and TypeMethodDescriptionvoidcreate()Creates reusable ui styles and adds actors to the stage.voiddraw(com.badlogic.gdx.graphics.g2d.SpriteBatch batch) Draws the resource bars on the screen.voidupdate()Called once per frame of the game, and should be used for most component logic.withResource(Resource resource) Adds a resource type to the display.Methods inherited from class com.csse3200.game.ui.UIComponent
getLayer, getZIndexMethods inherited from class com.csse3200.game.rendering.RenderComponent
compareTo, dispose, overrideZIndex, renderMethods inherited from class com.csse3200.game.components.Component
earlyUpdate, getEntity, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdateMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Comparable
compareToMethods inherited from interface com.csse3200.game.rendering.Renderable
render
-
Constructor Details
-
ResourceDisplay
public ResourceDisplay(int scale, int steps, int maxResource) Constructor for the ResourceDisplay. Initializes the table and maps used for storing resource bar data.
-
-
Method Details
-
create
public void create()Creates reusable ui styles and adds actors to the stage.- Overrides:
createin classUIComponent
-
update
public void update()Description copied from class:ComponentCalled once per frame of the game, and should be used for most component logic. Not called if component is disabled. -
withResource
Adds a resource type to the display.- Parameters:
resource- The type of resource to add.- Returns:
- Returns the updated ResourceDisplay object.
-
draw
public void draw(com.badlogic.gdx.graphics.g2d.SpriteBatch batch) Draws the resource bars on the screen. The drawing is managed by the stage.- Specified by:
drawin classRenderComponent- Parameters:
batch- The SpriteBatch used for drawing.
-