Im trying to make a menu screen using a StandardGame and BUI for the menu state:
public class Main {
public static void main(String[] args) throws Exception {
// Instantiate StandardGame
StandardGame game = new StandardGame("Eternal Dream", StandardGame.GameType.GRAPHICAL, null);
game.getSettings().setWidth(640);
game.getSettings().setHeight(480);
// Show settings screen
//if (GameSettingsPanel.prompt(game.getSettings())) {
// Start StandardGame, it will block until it has initialized successfully, then return
game.start();
// Create a DebugGameState - has all the built-in features that SimpleGame provides
// NOTE: for a distributable game implementation you'll want to use something like
// BasicGameState instead and provide control features yourself.
//BasicGameState global = new BasicGameState("global");
DebugGameState global = new DebugGameState();
// Add it to the manager
GameStateManager.getInstance().attachChild(global);
// Activate the game state
global.setActive(true);
GameState menu = new MenuGameState("menu");
GameStateManager.getInstance().attachChild(menu);
menu.setActive(true);
//}
}
}
public class MenuGameState extends BasicGameState {
/** The cursor node which holds the mouse gotten from input. */
private Node cursor;
/** Our display system. */
private DisplaySystem display;
private Text text;
private InputHandler input;
private Mouse mouse;
public MenuGameState(String name) {
super(name);
display = DisplaySystem.getDisplaySystem();
initInput();
initCursor();
//initText();
BuiSystem.init(new PolledRootNode(Timer.getTimer(), input), "/rsrc/style2.bss");
rootNode.attachChild(BuiSystem.getRootNode());
createWindows();
rootNode.setLightCombineMode(LightState.OFF);
rootNode.setRenderQueueMode(Renderer.QUEUE_ORTHO);
rootNode.updateRenderState();
rootNode.updateGeometricState(0, true);
}
private void createWindows() {
// TODO Auto-generated method stub
// add our login window to our BRootNode
MainMenu loginMenu = new MainMenu("menu");
BuiSystem.addWindow(loginMenu);
loginMenu.center();
}
...
but then, i got this error:
Exception in thread "main" java.lang.ExceptionInInitializerError
at com.jmex.bui.BStyleSheet$DefaultResourceProvider.loadImage(BStyleSheet.java:193)
at com.jmex.bui.BStyleSheet$BackgroundProperty.resolve(BStyleSheet.java:760)
at com.jmex.bui.BStyleSheet.getProperty(BStyleSheet.java:429)
at com.jmex.bui.BStyleSheet.findProperty(BStyleSheet.java:388)
at com.jmex.bui.BStyleSheet.getBackground(BStyleSheet.java:300)
at com.jmex.bui.BComponent.configureStyle(BComponent.java:789)
at com.jmex.bui.BTextComponent.configureStyle(BTextComponent.java:105)
at com.jmex.bui.BButton.configureStyle(BButton.java:193)
at com.jmex.bui.BComponent.wasAdded(BComponent.java:755)
at com.jmex.bui.BLabel.wasAdded(BLabel.java:164)
at com.jmex.bui.BContainer$2.apply(BContainer.java:323)
at com.jmex.bui.BContainer.applyOperation(BContainer.java:393)
at com.jmex.bui.BContainer.wasAdded(BContainer.java:321)
at com.jmex.bui.BContainer$2.apply(BContainer.java:323)
at com.jmex.bui.BContainer.applyOperation(BContainer.java:393)
at com.jmex.bui.BContainer.wasAdded(BContainer.java:321)
at com.jmex.bui.BWindow.setRootNode(BWindow.java:228)
at com.jmex.bui.BRootNode.addWindow(BRootNode.java:105)
at com.jmex.bui.BRootNode.addWindow(BRootNode.java:65)
at com.jmex.bui.BuiSystem.addWindow(BuiSystem.java:226)
at apalah.state.MenuGameState.createWindows(MenuGameState.java:106)
at apalah.state.MenuGameState.<init>(MenuGameState.java:87)
at Main.main(Main.java:58)
Caused by: java.lang.NullPointerException
at com.jmex.bui.BImage.<clinit>(BImage.java:392)
... 23 more
seems like BUI got an error when trying to add a window, but this error didnt occur when i used a BaseGame as a superclass,
could someone please help me? :(