Repository navigation
UiElements 1.3.0
This documentation is for 1.3.x
All ui elements extend the UiElement class. The following UI elements are currently supported by the framework:
- ContentButton
- Image
- ImageButton
- Label
- ProgressBar
- ScrollBox
- Select
- TabView
- Tab
- TextBox
- TextButton
On top of these elements, there are layout elements for structuring the UI.
Finally, to add your elements to the UiContainer, you must use one of the following:
The difference between a Modal and a Container is that a Modal can have navigation and hotkeys attached to it.
To simplify creating your UIs, all elements can be loaded and saved using Mdx.xml. The following example shows an AlignedModal which contains two Rows that have a TextButton each.
Note: the root element must always be called data.
<?xml version="1.0"?>
<data id="startGameModal">
<visibility>VISIBLE</visibility>
<verticalAlignment>BOTTOM</verticalAlignment>
<horizontalAlignment>CENTER</horizontalAlignment>
<children length="2">
<value class="org.mini2Dx.ui.element.Row" id="newGameRow">
<visibility>VISIBLE</visibility>
<children length="1">
<value class="org.mini2Dx.ui.element.TextButton" id="newGameButton">
<visibility>VISIBLE</visibility>
<text>New Game</text>
<textAlignment>CENTER</textAlignment>
</value>
</children>
</value>
<value class="org.mini2Dx.ui.element.Row" id="quitGameRow">
<visibility>VISIBLE</visibility>
<children length="1">
<value class="org.mini2Dx.ui.element.TextButton" id="quitGameButton">
<visibility>VISIBLE</visibility>
<text>New Game</text>
<textAlignment>CENTER</textAlignment>
</value>
</children>
</value>
</children>
</data>This can then be loaded using standard Mdx.xml calls.
AlignedModal modal = Mdx.xml.fromXml(Gdx.files.internal("startgamemodal.xml").reader(), AlignedModal.class);
uiContainer.add(modal);If you want to call methods on the UI elements, you look look them up by their ID.
TextButton newGameButton = (TextButton) modal.getElementById("newGameButton");Information on what XML fields are supported by different UiElements can be found on the UiElements XML wiki page.
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