-
Notifications
You must be signed in to change notification settings - Fork 0
Day and Night Cycle Clock UI
Jump to a section or return to Day and Night Cycle Summary here!
The clock is a source of information for the player to keep them on top of the day and night cycle. This was implemented as a UI element, DayNightClockComponent
, attached to the MainGameScreen
UI elements. The clock works similarly to the other UI elements present in the game, but is able to be updated through the EVENT_PART_OF_DAY_PASSED
.
The MainGameScreen has the following command for attaching the DayNighClockComponent to the screen and also loads the sprites for the clock. It helps in loading the assets which is further used in the DayNightClockComponent.
Entity ui = new Entity();
ui.addComponent(new InputDecorator(stage, 10))
.addComponent(new PerformanceDisplay())
.addComponent(new MainGameActions(this.game, MainArea.getInstance().getGameArea().getPlayer()))
.addComponent(new MainGameExitDisplay())
.addComponent(new MainGameInterface())
.addComponent(new MainGameBuildingInterface())
.addComponent(new DayNightClockComponent())
.addComponent(new Terminal())
.addComponent(inputComponent)
.addComponent(new TerminalDisplay());
ServiceLocator.getEntityService().registerNamed("ui", ui);
The function called addClock which takes care of bringing the sprite on and having it displayed using the table and stage commands.
private void addClock(){
rightTable = new Table();
rightTable.top().right();
rightTable.setFillParent(true);
rightTable.padTop(60f).padRight(10f);
//adding it on screen
rightTable.add(clockImage).left().bottom().size(200f, 200f);
stage.addActor(rightTable);
}
From the above video we can see the functionality of the clock in respect to the game. The clock has its section divided for each part of the cycle which represent the current part of the cycle. It change as the time passes in the game and have the number displayed showing the each cycle pass.