Skip to content

LosingScreen

SonjaMcNeilly edited this page Sep 12, 2023 · 8 revisions

Introduction

The Losing-Screen provides the user a menu for when a lose-game event has been triggered, which is when the engineer count drops to 0.

After clicking one of the planet events above you will load into a turret select screen, eventually taking you to the main game.

Development

The lose screen is set when a lose-event occurs. As a lose-event was not implemented during implementation, a lose button was constructed using 'class MainGameLoseDisplay' which listens for a a click and creates a 'lose' event. addActors() method:

private void addActors() {
    table = new Table();
    table.top().right();
    table.setFillParent(true);

    TextButton mainMenuBtn = new TextButton("Lose", skin);

    // Triggers an event when the button is pressed.
    mainMenuBtn.addListener(
            new ChangeListener() {
                @Override
                public void changed(ChangeEvent changeEvent, Actor actor) {
                    logger.debug("Lose button clicked");
                    entity.getEvents().trigger("lose");
                }
            });

    table.add(mainMenuBtn).padTop(-100).padBottom(-500);

    stage.addActor(table);
}

From this, an 'onLose()' method is made in 'class MainGameActions' which switches the screen to the Lose-Screen if the 'lose' event is triggered. 'onLose() method:'

private void onLose() {
    logger.info("Losing");
    game.setScreen(GdxGame.ScreenType.LOSING_SCREEN);
}

Changing level

The level is changed here. Each specific planet has an attached id to it, which can be used to set the screen to a certain level.

Test Plan

Due to the state of UI, it cannot be directly JUNIT/mockito tested. Here is a test plan for the screen.

  • Background appears
  • Display text correctly displays and animates
  • Planets appear in the correct position
  • Planets spin at the correct speed
  • When hovering a planet, the planet is highlighted with a blue indicator
  • When clicking a planet, screen correctly changes to the turret selection screen.

3 manual tests were conducted and a crash bug was found when clicking a planet, this is due to a resolution issue. See (Issue #149)

Clone this wiki locally