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 TypeMethodDescriptionvoid
create()
Creates the clock UI component and adds the event listener for EVENT_PART_OF_DAY_PASSED from DayNightCycleServicevoid
dispose()
Clears the current clock faceprotected void
draw
(com.badlogic.gdx.graphics.g2d.SpriteBatch batch) Draw the renderable.int
for testing purposesvoid
Loads the clock when a save is loaded.Methods inherited from class com.deco2800.game.ui.UIComponent
getLayer, getSkin, getZIndex
Methods inherited from class com.deco2800.game.rendering.RenderComponent
compareTo, render
Methods inherited from class com.deco2800.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.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:
create
in classUIComponent
-
dispose
public void dispose()Clears the current clock face- Specified by:
dispose
in interfacecom.badlogic.gdx.utils.Disposable
- Overrides:
dispose
in classRenderComponent
-
draw
protected void draw(com.badlogic.gdx.graphics.g2d.SpriteBatch batch) Description copied from class:RenderComponent
Draw the renderable. Should be called only by the renderer, not manually.- Specified by:
draw
in 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
-