hey,
i’m trying to set up some controls on my nifty gui. but every time i’ve started my game, i’ve got the following error:
[assets] Interface/GUI/GUI_01:
[xml]
<?xml version="1.0" encoding="UTF-8"?>
<nifty xmlns="http://nifty-gui.sourceforge.net/nifty-1.3.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://nifty-gui.sourceforge.net/nifty-1.3.xsd http://nifty-gui.sourceforge.net/nifty-1.3.xsd">
<useControls filename="nifty-default-controls.xml" />
<useStyles filename="nifty-wronguniverse-styles.xml" />
<screen id="loginscreen" controller="wronguniverse.appstates.StartScreenState"> <!-- CONTROLLER: controller="wronguniverse.Main" -->
<layer id="layer" childLayout="vertical" backgroundColor="#222" visibelToMouse="true">
<panel id="panel" height="10%" width="100%" align="center" valign="top" childLayout="center" visibleToMouse="true" backgroundColor="#333">
<text text="Wrong Universe - Anmelden"
font="Interface/Fonts/Default.fnt" width="100%" height="20%" wrap="true" />
</panel>
<panel id="vPanel" height="90%" width="100%" align="center" valign="top" childLayout="horizontal" visibleToMouse="true" backgroundColor="#222" border="2px">
<panel id="panel2" height="100%" width="29%" align="center" valign="top" childLayout="vertical" visibleToMouse="true" >
<panel id="pl001" height="5%"></panel>
<text text="Benutzername:"
font="Interface/Fonts/Default.fnt" width="100%" height="20%" wrap="true" />
<panel id="pl002" height="2%"></panel>
<control name="textfield" text="" id="username" width="75%" align="center"/>
<panel id="pl003" height="5%"></panel>
<text text="Passwort:"
font="Interface/Fonts/Default.fnt" width="100%" height="20%" wrap="true" />
<panel id="pl004" height="2%"></panel>
<control name="textfield" passwordChar="*" id="password" width="75%" align="center" />
<panel id="pl005" height="5%"></panel>
<control name="button" label="Start" id="StartButton" align="center" valign="center"
visibleToMouse="true" >
<interact onClick="nextScreen(startscreen)"/>
</control>
</panel>
<panel id="panel3" height="100%" width="1px" align="center" valign="top" childLayout="vertical" visibleToMouse="true" backgroundColor="#444">
</panel>
</panel>
</layer>
</screen>
...startscreen...
</nifty>
[/xml]
wronguniverse.appstates.StartScreenState:
[java]
package wronguniverse.appstates;
import ...
/**
*
* @author tom
*/
public class StartScreenState extends AbstractAppState implements ScreenController {
private ViewPort viewPort;
private ViewPort guiViewPort;
private Node rootNode;
private Node guiNode;
private InputManager inputManager;
private AssetManager assetManager;
private AudioRenderer audioRenderer;
private Node localRootNode = new Node("Startscreen rootnode");
private Node localGuiNode = new Node("Startscreen guinode");
private final ColorRGBA backgroundColor = ColorRGBA.Blue;
private ViewPort localGuiViewPort;
private NiftyJmeDisplay niftyDisplay;
private Nifty nifty;
private Screen screen;
public StartScreenState(SimpleApplication app) {
this.rootNode = app.getRootNode();
this.viewPort = app.getViewPort();
this.guiViewPort = app.getGuiViewPort();
this.guiNode = app.getGuiNode();
this.assetManager = app.getAssetManager();
this.inputManager = app.getInputManager();
this.audioRenderer = app.getAudioRenderer();
}
public void initialize(AppStateManager stateManager, Application app) {
super.initialize(stateManager, app);
/** Init this scene - Please Change content (remember the local nodes!) */
niftyDisplay = new NiftyJmeDisplay(assetManager,
inputManager,
audioRenderer,
guiViewPort);
nifty = niftyDisplay.getNifty();
nifty.fromXml("Interface/GUI/GUI_01.xml", "loginscreen");
guiViewPort.addProcessor(niftyDisplay);
inputManager.setCursorVisible(true);
//nifty.setDebugOptionPanelColors(true);
}
public void update(float tpf) {
}
@Override
public void stateAttached(AppStateManager stateManager) {
rootNode.attachChild(localRootNode);
guiNode.attachChild(localGuiNode);
viewPort.setBackgroundColor(backgroundColor);
super.setEnabled(true);
}
@Override
public void stateDetached(AppStateManager stateManager) {
guiViewPort.removeProcessor(niftyDisplay);
rootNode.detachChild(localRootNode);
guiNode.detachChild(localGuiNode);
super.setEnabled(false);
}
public void bind(Nifty nifty, Screen screen) {
//throw new UnsupportedOperationException("Not supported yet.");
this.nifty = nifty;
this.screen = screen;
}
public void onStartScreen() {
//throw new UnsupportedOperationException("Not supported yet.");
}
public void onEndScreen() {
//throw new UnsupportedOperationException("Not supported yet.");
}
//custom actions for controller nifty
public void nextScreen(String nextScreen) {
nifty.gotoScreen(nextScreen); // switch to another screen
// start the game and do some more stuff...
System.out.println("Yes clicked!");
}
}
[/java]