Class GameOverScene

java.lang.Object
application.GameOverScene

public class GameOverScene extends Object
Game Over screen displaying the winner and loser with animations. Supports both a normal result and a draw. Provides a Main Menu button and an Exit button.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private javafx.scene.media.MediaPlayer
    BGM media player.
    private javafx.scene.control.Button
    Button to exit the game.
    private final double
    X position of the left (loser) box.
    private final double
    Y position of the left box.
    private javafx.scene.control.Button
    Button to return to the Main Menu.
    private javafx.scene.layout.StackPane
    Root container.
    private final double
    X position of the right (winner) box.
    private final double
    Y position of the right box.
    private javafx.scene.layout.BorderPane
    Main layout.
    private javafx.scene.Scene
    Main JavaFX Scene for this screen.
  • Constructor Summary

    Constructors
    Constructor
    Description
    GameOverScene(String winnerName, String winnerClass, String loserName, String loserClass)
    Creates the Game Over screen displaying the battle result.
  • Method Summary

    Modifier and Type
    Method
    Description
    private javafx.scene.control.Button
    Creates an image-based button with a hover effect.
    private javafx.scene.layout.Pane
    createPlayerResult(String name, String className, String titleImagePath, boolean isWinner, boolean isRightSide)
    Creates a result box for one player (name + sprite + Victory/Defeat banner).
    javafx.scene.media.MediaPlayer
     
    javafx.scene.control.Button
     
    private String
    Converts a class name to the corresponding sprite folder name, normalising aliases.
    javafx.scene.control.Button
     
    javafx.scene.Scene
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • LEFT_POS_X

      private final double LEFT_POS_X
      X position of the left (loser) box.
      See Also:
    • LEFT_POS_Y

      private final double LEFT_POS_Y
      Y position of the left box.
      See Also:
    • RIGHT_POS_X

      private final double RIGHT_POS_X
      X position of the right (winner) box.
      See Also:
    • RIGHT_POS_Y

      private final double RIGHT_POS_Y
      Y position of the right box.
      See Also:
    • scene

      private javafx.scene.Scene scene
      Main JavaFX Scene for this screen.
    • mainRoot

      private javafx.scene.layout.StackPane mainRoot
      Root container.
    • rootPane

      private javafx.scene.layout.BorderPane rootPane
      Main layout.
    • exitBtn

      private javafx.scene.control.Button exitBtn
      Button to exit the game.
    • bgmPlayer

      private javafx.scene.media.MediaPlayer bgmPlayer
      BGM media player.
  • Constructor Details

    • GameOverScene

      public GameOverScene(String winnerName, String winnerClass, String loserName, String loserClass)
      Creates the Game Over screen displaying the battle result. If winnerName is "Draw", a draw result is shown instead.
      Parameters:
      winnerName - Name of the winner (or "Draw" for a draw)
      winnerClass - Class of the winner
      loserName - Name of the loser
      loserClass - Class of the loser
  • Method Details

    • createPlayerResult

      private javafx.scene.layout.Pane createPlayerResult(String name, String className, String titleImagePath, boolean isWinner, boolean isRightSide)
      Creates a result box for one player (name + sprite + Victory/Defeat banner). The sprite floats if the player won, or is desaturated if they lost.
      Parameters:
      name - Player name, e.g. "Player 1"
      className - Player class used to load the sprite
      titleImagePath - Path to the Victory/Defeat banner (null for a draw)
      isWinner - true if this player is the winner
      isRightSide - true if placed on the right side (sprite is flipped)
      Returns:
      The player result box as a Pane
    • getFolderByClass

      private String getFolderByClass(String className)
      Converts a class name to the corresponding sprite folder name, normalising aliases.
      Parameters:
      className - Class name to convert
      Returns:
      Folder name under /character/
    • createImageButton

      private javafx.scene.control.Button createImageButton(String imagePath)
      Creates an image-based button with a hover effect.
      Parameters:
      imagePath - Resource path for the button image
      Returns:
      A Button using an image instead of text
    • getScene

      public javafx.scene.Scene getScene()
      Returns:
      The Scene for the Game Over screen
    • getBgmPlayer

      public javafx.scene.media.MediaPlayer getBgmPlayer()
      Returns:
      The BGM MediaPlayer for stopping before switching screens
    • getMainMenuBtn

      public javafx.scene.control.Button getMainMenuBtn()
      Returns:
      The Main Menu button for GameController to bind an event handler
    • getExitBtn

      public javafx.scene.control.Button getExitBtn()
      Returns:
      The Exit button for GameController to bind an event handler