Skip to content

SidebarController

Paulius Imbrasas edited this page Jan 23, 2014 · 2 revisions

The class is responsible for handling anything that is related to the sidebar. Upon initialisation it creates and adds all of the buttons and text fields to the sidebar such as the turn left/right, increase/decrease altitude and others. As it contains all of the buttons, it also handles the input once one of those buttons have been clicked. Finally, when called from the AircraftController, it updates the text fields which display the selected aircraft’s speed and altitude.

Waypoint creation: ChangeListener.changed()allowNewWaypoints

When the user clicks the button labelled “Create Waypoint”, SidebarController acts as an input handler and detects that the button has been clicked. When it does, it sets the allowNewWaypoints which in turn is used in the AircraftController due to the fact that it handles all user input related to the airspace.

Selected aircraft information: update()

This method is called every iteration by the AircraftController to make sure it always has the newest available information about the selected aircraft. It essentially detects whether an aircraft has been selected and if so, get its details (altitude through getAltitude() and speed through getVelocity()) and updates the respective text fields.

Displaying timer to user: update()

As the requirements specify, the timer must always be visible to the user while he is playing the game. In order to solve that we simply have a text field which represents the time and is updated every frame. Internally is handled by the State described later class.

Clone this wiki locally