Class MainMenuScene

java.lang.Object
application.MainMenuScene

public class MainMenuScene extends Object
Main menu screen shown at game start. Displays a background image, plays music, and shows a single Start button. Pressing Start notifies GameController to begin a new game.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private javafx.scene.media.MediaPlayer
    Looping background music player.
    private javafx.scene.layout.StackPane
    Root layout for this screen.
    private javafx.scene.Scene
    Main JavaFX Scene for this screen.
    private javafx.scene.control.Button
    Start button that enters the game.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates the Main Menu screen with a background image, music, and a Start button.
  • Method Summary

    Modifier and Type
    Method
    Description
    javafx.scene.media.MediaPlayer
    Returns the background music MediaPlayer for stopping before switching screens.
    javafx.scene.Scene
    Returns the Scene for this screen to be set on the Stage.
    javafx.scene.control.Button
    Returns the Start button for GameController to bind an event handler.

    Methods inherited from class java.lang.Object

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

    • scene

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

      private javafx.scene.layout.StackPane mainRoot
      Root layout for this screen.
    • startBtn

      private javafx.scene.control.Button startBtn
      Start button that enters the game.
    • bgmPlayer

      private javafx.scene.media.MediaPlayer bgmPlayer
      Looping background music player.
  • Constructor Details

    • MainMenuScene

      public MainMenuScene()
      Creates the Main Menu screen with a background image, music, and a Start button. The button fades in slowly when the screen opens.
  • Method Details

    • getScene

      public javafx.scene.Scene getScene()
      Returns the Scene for this screen to be set on the Stage.
      Returns:
      The Main Menu Scene
    • getBgmPlayer

      public javafx.scene.media.MediaPlayer getBgmPlayer()
      Returns the background music MediaPlayer for stopping before switching screens.
      Returns:
      The BGM MediaPlayer
    • getStartBtn

      public javafx.scene.control.Button getStartBtn()
      Returns the Start button for GameController to bind an event handler.
      Returns:
      The Start button