GameOverScreen
Finally, we need a mechanism to enable the game to end and allow the player to reload from a previous save, since the element of the player character death naturally comes with adding a battle system. The following screenshot (Figure 11) represents the game over screen for BludBourne when the HP for the player's character reaches 0:
This screen will load the LoadGameScreen
when the Continue button is pressed, allowing the user to reload from a previous save game. The screen will also load the MainMenuScreen
when the Main Menu button is pressed. The workflow for enabling this screen starts with PlayerHUD
receiving a notification that the player has been damaged, as shown in the following code snippet:
public void onNotify(Entity enemyEntity, BattleEvent event) { switch (event) { ... case PLAYER_HIT_DAMAGE: int hpVal = ProfileManager.getInstance().getProperty( "currentPlayerHP", Integer.class); _statusUI.setHPValue(hpVal); ...