Repository navigation
UI Navigation
Requires mini2Dx 1.3.0 or above
mini2Dx's UI framework not only handles UI responding to different screen sizes, but also to different input sources. The Navigation API allows you to implement a navigable UI that considers both input source and current screen size, allowing you to implement your UI once for every platform.
Certain UiElements will implement the Navigatable interface which means children elements can be navigated.
Navigation layout is defined using an implementation of UiNavigation. The framework currently contains the following implementations:
- GridUiNavigation for grid-based UI navigation. This implementation allows you to set how many columns will be displayed at each screen size so that the navigation is reusable on every platform.
- VerticalUiNavigation for vertically stacked UI elements
The framework also has an internal TabViewUiNavigation class for the TabView. You should not need to access this class directly.
In the example below, we assume there are 2 buttons available for navigation. The buttons will be added to the modal and marked as a vertically navigable.
Modal modal = ...;
Button button1 = ...;
Button button2 = ...;
modal.add(button1);
modal.add(button2);
//Define the navigation structure
VerticalUiNavigation navigation = new VerticalUiNavigation();
navigation.add(button1);
navigation.add(button2);
//Define that the modal uses the navigation structure
modal.setNavigation(navigation);
//Set the modal as the active navigation
uiContainer.setActiveNavigation(modal);
...
//Clear the active navigation when finished navigating, e.g. a button is clicked
uiContainer.clearActiveNavigation();By default the UiContainer assumes mouse-based navigation on desktop. To enable keyboard-based navigation, use the setKeyboardNavigationEnabled method.
uiContainer.setKeyboardNavigationEnabled(true);If you want some elements to be hot-keyable (e.g. pressing Q instead of having to select an element), each Navigatable implementation supports mapping Actionable elements as hot key actions.
Modal modal = ...;
Button button = ...;
//Set Q as hotkey to trigger the button click
modal.setHotkey(Keys.Q, button);
//Set Xbox 360 controller A button as hotkey to trigger the button click
modal.setHotkey(Xbox360Button.A, button);Getting Started
Graphics
Gameplay
Data
- Asset Management
- Saving and loading player data
- Converting objects to/from JSON
- Converting objects to/from XML
User Interfaces / HUDs
Structuring your code
Releasing your game