Class GameWindow

java.lang.Object
de.gurkenlabs.litiengine.GameWindow

public final class GameWindow extends Object
The GameWindow class is a wrapper for the game's visual window in which the RenderComponent lives.
It provides the possibility to set a title, provide an icon, configure the cursor or get information about the resolution.
See Also:
  • Method Details

    • isFocusOwner

      public boolean isFocusOwner()
      Returns true if the GameWindow is the focus owner.
      Returns:
      true if the GameWindow is the focus owner; false otherwise
    • onResolutionChanged

      public void onResolutionChanged(GameWindow.ResolutionChangedListener listener)
      Adds the specified resolution changed listener to receive events when the dimensions of this game window are changed.
      Parameters:
      listener - The listener to add.
    • removeResolutionChangedListener

      public void removeResolutionChangedListener(GameWindow.ResolutionChangedListener listener)
      Removes the specified resolution changed listener.
      Parameters:
      listener - The listener to remove.
    • setResolution

      public void setResolution(Resolution res)
      Sets the resolution for the GameWindow.
      Parameters:
      res - The desired Resolution to set for the GameWindow.
      See Also:
    • getResolutionScale

      public float getResolutionScale()
      Gets the current resolution scale. The resolution scale is a float value dictating how much larger or smaller each pixel is rendered on screen.
      Returns:
      The GameWindow's current resolution scale.
    • getCenter

      public Point2D getCenter()
      Gets the current resolution scale. The resolution scale is a float value dictating how much larger or smaller each pixel is rendered on screen.
      Returns:
      The GameWindow's current resolution scale.
    • getHostControl

      public Container getHostControl()
      Gets the GameWindow's JFrame, abstracted as a Container.
      Returns:
      The GameWindow's JFrame as an abstract AWT Container.
    • getSize

      public Dimension getSize()
      Gets the window width and height wrapped in a Dimension object.
      Returns:
      The GameWindow's size as a Dimension.
    • getWidth

      public int getWidth()
      Gets the window width.
      Returns:
      The window width.
    • getHeight

      public int getHeight()
      Gets the window height.
      Returns:
      The window height.
    • getRenderComponent

      public RenderComponent getRenderComponent()
      Gets the AWT canvas that is used to render the game's content on.
      Returns:
      The AWT render component onto which the game contents are rendered.
    • cursor

      public MouseCursor cursor()
      Gets the visual representation of the mouse cursor on the GameWindow.

      This can be used to provide a custom cursor image, define its visibility or specify a rendering offset from the actual position.

      Returns:
      The mouse cursor of the game.
    • getResolution

      public Dimension getResolution()
      Gets the window resolution wrapped in a Dimension object.
      Returns:
      The GameWindow's internal resolution as a Dimension.
    • getLocationOnScreen

      public Point getLocationOnScreen()
      Gets the screen location of the window's top left corner.
      Returns:
      The Point of the window's top left corner.
      See Also:
    • setIcon

      public void setIcon(Image image)
      Sets the icon image for the window's hosting JFrame.
      Parameters:
      image - The Image to be used as the window icon.
      See Also:
    • setIcons

      public void setIcons(List<? extends Image> images)
      Sets the icons for the window's hosting JFrame. Depending on the platform specifications, one or several Icons with the correct Dimension will be chosen automatically from the list.
      Parameters:
      images - A list of Images to be used as the window icons.
      See Also:
    • setTitle

      public void setTitle(String title)
      Sets the title for this window to the specified string.
      Parameters:
      title - the window title to be displayed in the frame's border. A null value is treated as an empty string, "".
      See Also: