java.lang.Object
technology.sola.engine.core.SolaPlatform
SolaPlatform defines the API for a platform to run
Sola.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static interfaceGameLoopProvider is aFunctionalInterfacedefining the contract for providing aGameLoopimplementation for the sola game engine to use.protected static final recordHolds the coordinate of the pointer.protected static interfaceSolaPlatformInitialization is aFunctionalInterfacedefining the contract for finishing initialization of aSolaPlatform. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected GameLoopTheGameLoopfor the platform.protected RendererTheRendererfor the platform.protected final RestClientTheRestClientfor the platform.protected final SaveStorageTheSaveStoragefor the platform.protected final SocketClientTheSocketClientfor the platform.protected EventHubprotected ViewportTheViewportfor the platform. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSolaPlatform(SocketClient socketClient, RestClient restClient, SaveStorage saveStorage) InitializesSolaPlatforminternals. -
Method Summary
Modifier and TypeMethodDescriptionprotected SolaPlatform.PointerCoordinateadjustPointerForViewport(float x, float y) Convenience method for calculating adjusted pointer coordinate considering the currentAspectModeof theViewport.protected SolaPlatform.PointerCoordinateadjustPointerForViewport(int x, int y) Convenience method for calculating adjusted pointer coordinate considering the currentAspectModeof theViewport.protected abstract voidbeforeRender(Renderer renderer) Method called before each render frame.protected SolaPlatform.GameLoopProviderBuilds theGameLoopfor this platform.protected RendererbuildRenderer(SolaConfiguration solaConfiguration) Builds theRendererfor this platform.abstract SolaPlatformIdentifierprotected abstract voidinitializePlatform(SolaConfiguration solaConfiguration, SolaPlatform.SolaPlatformInitialization solaPlatformInitialization) Method to initialize aSolaPlatform.abstract SubscriptiononKeyPressed(Consumer<KeyEvent> keyEventConsumer) Registers an on key pressed listener.abstract SubscriptiononKeyReleased(Consumer<KeyEvent> keyEventConsumer) Registers an on key released listener.abstract SubscriptiononMouseMoved(Consumer<MouseEvent> mouseEventConsumer) Registers an on mouse moved listener.abstract SubscriptiononMousePressed(Consumer<MouseEvent> mouseEventConsumer) Registers an on mouse pressed listener.abstract SubscriptiononMouseReleased(Consumer<MouseEvent> mouseEventConsumer) Registers an on mouse released listener.abstract SubscriptiononMouseWheel(Consumer<MouseWheelEvent> mouseWheelEventConsumer) Registers an on mouse wheel listener.protected abstract voidMain render frame method.abstract SubscriptiononTouch(Consumer<TouchEvent> touchEventConsumer) Registers an on touch listener.voidMain entry point for starting aSola.protected abstract voidpopulateAssetLoaderProvider(AssetLoaderProvider assetLoaderProvider) Method to populate theSolaPlatformAssetLoaderProviderwithAssetLoaders thatSolawill be able to use.abstract voidsetVirtualKeyboardVisible(boolean visible) Sets the visibility of the virtual keyboard.
-
Field Details
-
socketClient
TheSocketClientfor the platform. -
restClient
TheRestClientfor the platform. -
saveStorage
TheSaveStoragefor the platform. -
renderer
TheRendererfor the platform. -
gameLoop
TheGameLoopfor the platform. -
viewport
TheViewportfor the platform. -
solaEventHub
-
-
Constructor Details
-
SolaPlatform
InitializesSolaPlatforminternals.- Parameters:
socketClient- theSocketClientfor the platformrestClient- theRestClientfor the platformsaveStorage- theSaveStoragefor the platform
-
-
Method Details
-
play
Main entry point for starting aSola.- Parameters:
sola- theSolato start
-
getRenderer
- Returns:
- the platform's
Renderer
-
getViewport
- Returns:
- the platform's
Viewport
-
getSocketClient
- Returns:
- the platform's
SocketClient
-
getRestClient
- Returns:
- the platform's
RestClient
-
getSaveStorage
- Returns:
- the platform's
SaveStorage
-
getIdentifier
- Returns:
- the platform's identifier
-
onKeyPressed
Registers an on key pressed listener.- Parameters:
keyEventConsumer- the method called when key is pressed- Returns:
- an
Subscriptioninstance that can be used to unsubscribe the listener
-
onKeyReleased
Registers an on key released listener.- Parameters:
keyEventConsumer- the method called when the key is released- Returns:
- an
Subscriptioninstance that can be used to unsubscribe the listener
-
onMouseMoved
Registers an on mouse moved listener.- Parameters:
mouseEventConsumer- the method called when mouse is moved- Returns:
- an
Subscriptioninstance that can be used to unsubscribe the listener
-
onMousePressed
Registers an on mouse pressed listener.- Parameters:
mouseEventConsumer- the method called when mouse is pressed- Returns:
- an
Subscriptioninstance that can be used to unsubscribe the listener
-
onMouseReleased
Registers an on mouse released listener.- Parameters:
mouseEventConsumer- the method called when mouse is released- Returns:
- an
Subscriptioninstance that can be used to unsubscribe the listener
-
onMouseWheel
Registers an on mouse wheel listener.- Parameters:
mouseWheelEventConsumer- the method called when a mouse wheel interaction takes place- Returns:
- an
Subscriptioninstance that can be used to unsubscribe the listener
-
onTouch
Registers an on touch listener.- Parameters:
touchEventConsumer- the method called when a touch interaction takes place- Returns:
- an
Subscriptioninstance that can be used to unsubscribe the listener
-
setVirtualKeyboardVisible
public abstract void setVirtualKeyboardVisible(boolean visible) Sets the visibility of the virtual keyboard.- Parameters:
visible- whether the virtual keyboard should be visible or not
-
initializePlatform
protected abstract void initializePlatform(SolaConfiguration solaConfiguration, SolaPlatform.SolaPlatformInitialization solaPlatformInitialization) Method to initialize aSolaPlatform. This operation can be async. It will provide the configuration from the).- Parameters:
solaConfiguration- the Sola configurationsolaPlatformInitialization- callSolaPlatform.SolaPlatformInitialization.finish()when platform initialization is finished
-
beforeRender
Method called before each render frame.- Parameters:
renderer- theRenderer
-
onRender
Main render frame method.- Parameters:
renderer- theRenderer
-
populateAssetLoaderProvider
Method to populate theSolaPlatformAssetLoaderProviderwithAssetLoaders thatSolawill be able to use.- Parameters:
assetLoaderProvider- theAssetLoaderProvider
-
buildRenderer
Builds theRendererfor this platform. Default implementation will use theSoftwareRendererimplementation.- Parameters:
solaConfiguration- theSolaConfigurationfor theSola- Returns:
- the built
Renderer
-
buildGameLoop
Builds theGameLoopfor this platform. Default implementation will use theFixedUpdateGameLoopimplementation.- Returns:
- the built
GameLoop
-
adjustPointerForViewport
Convenience method for calculating adjusted pointer coordinate considering the currentAspectModeof theViewport.- Parameters:
x- the raw x coordinate of the pointery- the raw y coordinate of the pointer- Returns:
- the viewport adjusted pointer coordinate
-
adjustPointerForViewport
Convenience method for calculating adjusted pointer coordinate considering the currentAspectModeof theViewport.- Parameters:
x- the raw x coordinate of the pointery- the raw y coordinate of the pointer- Returns:
- the viewport adjusted pointer coordinate
-