At what point can I use TWLStateBasedGame.getGUI()? I'm trying to set some image overlays for my button hotbar, but getGUI() is still null at this point. Is there a different function I can use for this kind of initialization after the GUI is instantiated?
Code:
public class MyGameplayState extends BasicTWLGameState {
private Button[] m_hotbar = new Button[10];
...
@Override
protected void createRootPane() {
....
// set overlay images for my buttons
Renderer renderer = m_game.getGUI().getRenderer();
for (int i = 0; i < m_hotbar.length; ++i) {
String path = "icons/" + m_hotbarActions[i].getIconName();
try {
Texture texture = renderer.loadTexture(new File(path).toURI().toURL(), "COLOR", "LINEAR");
de.matthiasmann.twl.renderer.Image img = texture.getImage(0, 0, texture.getWidth(), texture.getHeight(), de.matthiasmann.twl.Color.WHITE, false, Texture.Rotation.NONE);
m_hotbar[i].setOverlay(img);
} catch(Exception exc) {
LOGGER.error("Failed to load hotbar image: " + exc);
}
}
}
}