Class GameOverScene
java.lang.Object
application.GameOverScene
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
FieldsModifier and TypeFieldDescriptionprivate javafx.scene.media.MediaPlayerBGM media player.private javafx.scene.control.ButtonButton to exit the game.private final doubleX position of the left (loser) box.private final doubleY position of the left box.private javafx.scene.control.ButtonButton to return to the Main Menu.private javafx.scene.layout.StackPaneRoot container.private final doubleX position of the right (winner) box.private final doubleY position of the right box.private javafx.scene.layout.BorderPaneMain layout.private javafx.scene.SceneMain JavaFX Scene for this screen. -
Constructor Summary
ConstructorsConstructorDescriptionGameOverScene(String winnerName, String winnerClass, String loserName, String loserClass) Creates the Game Over screen displaying the battle result. -
Method Summary
Modifier and TypeMethodDescriptionprivate javafx.scene.control.ButtoncreateImageButton(String imagePath) Creates an image-based button with a hover effect.private javafx.scene.layout.PanecreatePlayerResult(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.MediaPlayerjavafx.scene.control.Buttonprivate StringgetFolderByClass(String className) Converts a class name to the corresponding sprite folder name, normalising aliases.javafx.scene.control.Buttonjavafx.scene.ScenegetScene()
-
Field Details
-
LEFT_POS_X
private final double LEFT_POS_XX position of the left (loser) box.- See Also:
-
LEFT_POS_Y
private final double LEFT_POS_YY position of the left box.- See Also:
-
RIGHT_POS_X
private final double RIGHT_POS_XX position of the right (winner) box.- See Also:
-
RIGHT_POS_Y
private final double RIGHT_POS_YY position of the right box.- See Also:
-
scene
private javafx.scene.Scene sceneMain JavaFX Scene for this screen. -
mainRoot
private javafx.scene.layout.StackPane mainRootRoot container. -
rootPane
private javafx.scene.layout.BorderPane rootPaneMain layout. -
mainMenuBtn
private javafx.scene.control.Button mainMenuBtnButton to return to the Main Menu. -
exitBtn
private javafx.scene.control.Button exitBtnButton to exit the game. -
bgmPlayer
private javafx.scene.media.MediaPlayer bgmPlayerBGM media player.
-
-
Constructor Details
-
GameOverScene
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 winnerloserName- Name of the loserloserClass- 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 spritetitleImagePath- Path to the Victory/Defeat banner (nullfor a draw)isWinner-trueif this player is the winnerisRightSide-trueif placed on the right side (sprite is flipped)- Returns:
- The player result box as a Pane
-
getFolderByClass
-
createImageButton
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
-