Class Application

All Implemented Interfaces:
Behavior, Closeable, AutoCloseable

public class Application extends AbstractBehavior
This class represents the main application. It is responsible for managing scenes, rendering, and updating entities. It also provides methods for interacting with the application platform and managing input.
  • Field Details

    • mousePosition

      public final Vector2D mousePosition
  • Constructor Details

    • Application

      public Application(ApplicationManager applicationManager, Class<? extends Scene> initialScene, ApplicationPlatform applicationPlatform, PlatformInit platformInit)
      Constructs a new Application instance.
      Parameters:
      applicationManager - The application manager.
      initialScene - The initial scene class.
      applicationPlatform - The application platform.
      platformInit - The platform initialization parameters.
    • Application

      public Application(ApplicationManager applicationManager, ApplicationPlatform applicationPlatform, PlatformInit platformInit)
      Constructs a new Application instance with a default blank scene.
      Parameters:
      applicationManager - The application manager.
      applicationPlatform - The application platform.
      platformInit - The platform initialization parameters.
  • Method Details

    • onStart

      public void onStart()
      Description copied from interface: Behavior
      This method is called when the behavior is started. It is typically used to initialize any necessary state or resources.
    • onUpdate

      public void onUpdate(ContextTime time)
      Description copied from interface: Behavior
      This method is called when the behavior needs to be updated with the current time. It is typically used to perform any necessary calculations or updates based on the current time.
      Parameters:
      time - The current time context.
    • close

      public void close() throws IOException
      Throws:
      IOException
    • isKeyPressed

      public boolean isKeyPressed(Input.Key key)
      Checks if a key is currently pressed.
      Parameters:
      key - The key to check.
      Returns:
      True if the key is pressed, false otherwise.
    • isMouseButtonPressed

      public boolean isMouseButtonPressed(Input.MouseButton mouseButton)
      Checks if a mouse button is currently pressed.
      Parameters:
      mouseButton - The mouse button to check.
      Returns:
      True if the mouse button is pressed, false otherwise.
    • setScene

      public Application setScene(Scene scene) throws IOException
      Sets the current scene and disposes of any previous scene and its entities and systems.
      Parameters:
      scene - The new scene.
      Returns:
      The application instance for method chaining.
      Throws:
      IOException - If an I/O error occurs.
    • mousePosition

      public Vector2D mousePosition()
      Gets the current mouse position.
      Returns:
      The current mouse position.
    • applicationPlatform

      public ApplicationPlatform applicationPlatform()
      Gets the application platform.
      Returns:
      The application platform.
    • platformInit

      public PlatformInit platformInit()
      Gets the platform initialization parameters.
      Returns:
      The platform initialization parameters.
    • applicationManager

      public ApplicationManager applicationManager()
      Gets the application manager.
      Returns:
      The application manager.
    • viewportSize

      public Vector2D viewportSize()
      Gets the viewport size.
      Returns:
      The viewport size.
    • scene

      public Scene scene()
      Gets the current scene.
      Returns:
      The current scene.
    • defaultFont

      public Font defaultFont()
      Gets the default font.
      Returns:
      The default font.
    • setDefaultFont

      public Application setDefaultFont(Font defaultFont)
      Sets the default font.
      Parameters:
      defaultFont - The new default font.
      Returns:
      The application instance for method chaining.
    • defaultTexture

      public Texture defaultTexture()
      Gets the default texture.
      Returns:
      The default texture.
    • setDefaultTexture

      public Application setDefaultTexture(Texture defaultTexture)
      Sets the default texture.
      Parameters:
      defaultTexture - The new default texture.
      Returns:
      The application instance for method chaining.
    • axis

      public double axis(String axisName)
      Gets the value of an axis based on the specified axis name.
      Parameters:
      axisName - The name of the axis.
      Returns:
      The value of the axis (-1, 0, or 1).
    • axis2D

      public Vector2D axis2D(String xAxis, String yAxis)
      Gets a 2D axis vector based on the specified x and y-axis names.
      Parameters:
      xAxis - The name of the x-axis.
      yAxis - The name of the y-axis.
      Returns:
      The 2D axis vector.
    • axisMap

      public Map<String,Axis> axisMap()
      Gets the map of axis configurations.
      Returns:
      The map of axis configurations.
    • setAxisMap

      public Application setAxisMap(Map<String,Axis> axisMap)
      Sets the map of axis configurations.
      Parameters:
      axisMap - The new map of axis configurations.
      Returns:
      The application instance for method chaining.