Package com.xebisco.yield
Class Application
java.lang.Object
com.xebisco.yield.AbstractBehavior
com.xebisco.yield.Application
- All Implemented Interfaces:
Behavior,Closeable,AutoCloseable
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 Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionApplication(ApplicationManager applicationManager, ApplicationPlatform applicationPlatform, PlatformInit platformInit) Constructs a new Application instance with a default blank scene.Application(ApplicationManager applicationManager, Class<? extends Scene> initialScene, ApplicationPlatform applicationPlatform, PlatformInit platformInit) Constructs a new Application instance. -
Method Summary
Modifier and TypeMethodDescriptionGets the application manager.Gets the application platform.doubleGets the value of an axis based on the specified axis name.Gets a 2D axis vector based on the specified x and y-axis names.axisMap()Gets the map of axis configurations.voidclose()Gets the default font.Gets the default texture.booleanisKeyPressed(Input.Key key) Checks if a key is currently pressed.booleanisMouseButtonPressed(Input.MouseButton mouseButton) Checks if a mouse button is currently pressed.Gets the current mouse position.voidonStart()This method is called when the behavior is started.voidonUpdate(ContextTime time) This method is called when the behavior needs to be updated with the current time.Gets the platform initialization parameters.scene()Gets the current scene.setAxisMap(Map<String, Axis> axisMap) Sets the map of axis configurations.setDefaultFont(Font defaultFont) Sets the default font.setDefaultTexture(Texture defaultTexture) Sets the default texture.Sets the current scene and disposes of any previous scene and its entities and systems.Gets the viewport size.Methods inherited from class com.xebisco.yield.AbstractBehavior
frames, tick
-
Field Details
-
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:BehaviorThis method is called when the behavior is started. It is typically used to initialize any necessary state or resources. -
onUpdate
Description copied from interface:BehaviorThis 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
- Throws:
IOException
-
isKeyPressed
Checks if a key is currently pressed.- Parameters:
key- The key to check.- Returns:
- True if the key is pressed, false otherwise.
-
isMouseButtonPressed
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
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
Gets the current mouse position.- Returns:
- The current mouse position.
-
applicationPlatform
Gets the application platform.- Returns:
- The application platform.
-
platformInit
Gets the platform initialization parameters.- Returns:
- The platform initialization parameters.
-
applicationManager
Gets the application manager.- Returns:
- The application manager.
-
viewportSize
Gets the viewport size.- Returns:
- The viewport size.
-
scene
Gets the current scene.- Returns:
- The current scene.
-
defaultFont
Gets the default font.- Returns:
- The default font.
-
setDefaultFont
Sets the default font.- Parameters:
defaultFont- The new default font.- Returns:
- The application instance for method chaining.
-
defaultTexture
Gets the default texture.- Returns:
- The default texture.
-
setDefaultTexture
Sets the default texture.- Parameters:
defaultTexture- The new default texture.- Returns:
- The application instance for method chaining.
-
axis
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
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
Gets the map of axis configurations.- Returns:
- The map of axis configurations.
-
setAxisMap
Sets the map of axis configurations.- Parameters:
axisMap- The new map of axis configurations.- Returns:
- The application instance for method chaining.
-