Class Menu

java.lang.Object
dev.kyzel.game.menu.Menu
Direct Known Subclasses:
TextMenu

public abstract class Menu extends Object
The menu super class.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected int
    The alignment of the menu.
    protected int
    The height of the menu.
    protected Renderer
    The Renderer where the menu will be drawn on.
    protected int
    The width of the menu.
    protected int
    The x coordinate of the menu.
    static final int
    The constant for the center alignment on the x-axis.
    static final int
    The constant for the left alignment.
    static final int
    The constant for the right alignment.
    protected int
    The y coordinate of the menu.
    static final int
    The constant for the bottom alignment.
    static final int
    The constant for the center alignment on the y-axis.
    static final int
    The constant for the top alignment.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Menu(Renderer render)
    Creates a new menu with no information, aligned to the center of the screen by default.
    Menu(Renderer render, int alignment)
    Creates a menu without x, y coordinates and width, height.
    Menu(Renderer render, int x, int y, int width, int height)
    Creates a new menu, aligned to the center of the screen by default.
    Menu(Renderer render, int x, int y, int width, int height, int alignment)
    Creates a new menu.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Draws the container of the menu.
    int
    Gets the x-axis alignment.
    int
    Gets the y-axis alignment.

    Methods inherited from class java.lang.Object

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

    • X_LEFT

      public static final int X_LEFT
      The constant for the left alignment.
      See Also:
    • X_CENTER

      public static final int X_CENTER
      The constant for the center alignment on the x-axis.
      See Also:
    • X_RIGHT

      public static final int X_RIGHT
      The constant for the right alignment.
      See Also:
    • Y_TOP

      public static final int Y_TOP
      The constant for the top alignment.
      See Also:
    • Y_CENTER

      public static final int Y_CENTER
      The constant for the center alignment on the y-axis.
      See Also:
    • Y_BOTTOM

      public static final int Y_BOTTOM
      The constant for the bottom alignment.
      See Also:
    • render

      protected Renderer render
      The Renderer where the menu will be drawn on.
    • x

      protected int x
      The x coordinate of the menu.
    • y

      protected int y
      The y coordinate of the menu.
    • width

      protected int width
      The width of the menu.
    • height

      protected int height
      The height of the menu.
    • alignment

      protected int alignment
      The alignment of the menu.
  • Constructor Details

    • Menu

      public Menu(Renderer render, int x, int y, int width, int height, int alignment)
      Creates a new menu.
      Parameters:
      render - the Renderer where the menu will be drawn on
      x - the x coordinate
      y - the y coordinate
      width - the width of the menu
      height - the height of the menu
      alignment - the alignment of the menu
    • Menu

      public Menu(Renderer render, int x, int y, int width, int height)
      Creates a new menu, aligned to the center of the screen by default.
      Parameters:
      render - the Renderer where the menu will be drawn on
      x - the x coordinate
      y - the y coordinate
      width - the width of the menu
      height - the height of the menu
    • Menu

      public Menu(Renderer render, int alignment)
      Creates a menu without x, y coordinates and width, height.
      Parameters:
      render - the Renderer where the menu will be drawn on
      alignment - the alignment of the menu
    • Menu

      public Menu(Renderer render)
      Creates a new menu with no information, aligned to the center of the screen by default.
      Parameters:
      render - the Renderer where the menu will be drawn on
  • Method Details

    • getXAlignment

      public int getXAlignment()
      Gets the x-axis alignment.
      Returns:
      the x-axis alignment
    • getYAlignment

      public int getYAlignment()
      Gets the y-axis alignment.
      Returns:
      the y-axis alignment
    • draw

      public void draw(Graphics g)
      Draws the container of the menu.
      Parameters:
      g - the Graphics which is used to draw