Package com.deco2800.game.components
Class DayNightClockComponent
java.lang.Object
com.deco2800.game.components.Component
com.deco2800.game.rendering.RenderComponent
com.deco2800.game.ui.UIComponent
com.deco2800.game.components.DayNightClockComponent
- All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable,Renderable,Comparable<Renderable>
Defines a Clock UI element that displays the current phase of the day/night cycle
-
Field Summary
Fields inherited from class com.deco2800.game.ui.UIComponent
skin, stage -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcreate()Creates the clock UI component and adds the event listener for EVENT_PART_OF_DAY_PASSED from DayNightCycleServicevoiddispose()Clears the current clock faceprotected voiddraw(com.badlogic.gdx.graphics.g2d.SpriteBatch batch) Draw the renderable.intfor testing purposesvoidLoads the clock when a save is loaded.Methods inherited from class com.deco2800.game.ui.UIComponent
getLayer, getSkin, getZIndexMethods inherited from class com.deco2800.game.rendering.RenderComponent
compareTo, renderMethods inherited from class com.deco2800.game.components.Component
earlyUpdate, getEntity, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate, updateMethods 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.deco2800.game.rendering.Renderable
render
-
Constructor Details
-
DayNightClockComponent
public DayNightClockComponent()
-
-
Method Details
-
create
public void create()Creates the clock UI component and adds the event listener for EVENT_PART_OF_DAY_PASSED from DayNightCycleService- Overrides:
createin classUIComponent
-
dispose
public void dispose()Clears the current clock face- Specified by:
disposein interfacecom.badlogic.gdx.utils.Disposable- Overrides:
disposein classRenderComponent
-
draw
protected void draw(com.badlogic.gdx.graphics.g2d.SpriteBatch batch) Description copied from class:RenderComponentDraw the renderable. Should be called only by the renderer, not manually.- Specified by:
drawin classRenderComponent- Parameters:
batch- Batch to render to.
-
loadFromSave
public void loadFromSave()Loads the clock when a save is loaded. Sets the current sprite equal to the current DayNightCycle day number and status -
getCurrentSprite
public int getCurrentSprite()for testing purposes- Returns:
- index of the current sprite
-