Cant get nifty to work with android correctly …
I made this screen with nifty:
startScreen
If i click Load Game the loadGame screen appears as it should:
loadScreen
But if i click on Start, nothing happens. I saw I am getting an Warning:
W/de.lessvoid.nifty.elements.Element(30590): WARNING missing element/control with id [StartButton#text] for requested control class [de.lessvoid.nifty.controls.TextField]
My screen.xml is:
[java]
<?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”>
<useStyles filename=“nifty-default-styles.xml” />
<useControls filename=“nifty-default-controls.xml” />
<registerSound id=“myclick” filename=“Sounds/GUI/ButtonClick.ogg” />
<!-- rezise Image, mark the edges"15,x,x,x" … and stretches it -->
<controlDefinition name = “loadingbar” controller = “mygame.Game”>
<image filename=“Interface/border.png” childLayout=“absolute”
imageMode=“resize:15,2,15,15,15,2,15,2,15,2,15,15”>
<image id=“progressbar” x=“0” y=“0” filename=“Interface/inner.png” width=“32px” height=“100%”
imageMode=“resize:15,2,15,15,15,2,15,2,15,2,15,15” />
</image>
</controlDefinition>
<screen id=“startScreen” controller=“mygame.StartScreenState” >
<layer id=“background” backgroundImage=“Interface/StartScreen.png” childLayout=“center”></layer>
<layer id=“foreground” childLayout=“vertical”>
<panel id=“panel_top” height=“25%” width=“75%” align=“center” childLayout=“center”>
<text font=“Interface/Fonts/Default.fnt” color="#000f" width=“100%” height=“100%” text=“Welcome” />
</panel>
<panel id=“panel_mid” height=“25%” width=“75%” align=“center” childLayout=“center”>
<text font=“Interface/Fonts/Default.fnt” color="#000f" width=“100%” height=“100%” wrap=“true” text=“Your job is Find and Solve the forgotten hints in the world” />
</panel>
<panel id=“panel_bottom” height=“50%” width=“75%” align=“center” childLayout=“horizontal” >
<panel id=“panel_bottom_left” height=“90%” width=“60%” childLayout=“center”></panel>
<panel id=“panel_bottom_right” height=“90%” width=“40%” childLayout=“vertical”>
<panel id=“startPanel” height=“30%” width=“100%” childLayout=“center”>
<control name=“button” label=“Start” id=“StartButton” height=“100%” width=“100%” align=“center” valign=“center” visibleToMouse=“true” >
<effect>
<onClick name=“playSound” sound=“myclick”/>
</effect>
<interact onClick=“loadGameSave(0)”/>
</control>
</panel>
<panel id=“loadPanel” height=“40%” width=“100%” childLayout=“center”>
<control name=“button” label=“Load Game” id=“LoadGame” height=“75%” width=“100%” align=“center” valign=“center” visibleToMouse=“true”>
<effect>
<onClick name=“playSound” sound=“myclick”/>
</effect>
<interact onClick=“nextScreen(loadScreen)”/>
</control>
</panel>
<panel id="quitPanel " height=“30%” width=“100%” childLayout=“center”>
<control name=“button” label=“Quit” id=“QuitButton” height=“100%” width=“100%” align=“center” valign=“center” visibleToMouse=“true”>
<effect>
<onClick name=“playSound” sound=“myclick”/>
</effect>
<interact onClick=“exit()”/>
</control>
</panel>
</panel>
</panel>
</layer>
</screen>
<screen id=“loadScreen” controller=“mygame.StartScreenState”>
<layer id=“background” backgroundImage=“Interface/LoadScreen.png” childLayout=“center”></layer>
<layer id=“foreground” childLayout=“vertical”>
<panel id=“panel1” height=“40%” width=“75%” align=“center” childLayout=“vertical”> </panel>
<panel id=“panel2” height=“25%” width=“75%” align=“center” childLayout=“horizontal”>
<panel id=“panel_left” height=“100%” width=“30%” valign=“center” childLayout=“center”>
<control name=“button” label=“Save 1” id=“SaveGame1” height=“100%” width=“100%” align=“center” valign=“center” visibleToMouse=“true” >
<effect>
<onClick name=“playSound” sound=“myclick”/>
</effect>
<interact onClick=“loadGameSave(1)”/>
</control>
</panel>
<panel id=“panel_center” height=“100%” width=“40%” valign=“center” childLayout=“center”>
<control name=“button” label=“Save 2” id=“SaveGame2” height=“100%” width=“75%” align=“center” valign=“center” visibleToMouse=“true”>
<effect>
<onClick name=“playSound” sound=“myclick”/>
</effect>
<interact onClick=“loadGameSave(2)”/>
</control>
</panel>
<panel id=“panel_right” height=“100%” width=“30%” valign=“center” childLayout=“center”>
<control name=“button” label=“Save 3” id=“SaveGame3” height=“100%” width=“100%” align=“center” valign=“center” visibleToMouse=“true”>
<effect>
<onClick name=“playSound” sound=“myclick”/>
</effect>
<interact onClick=“loadGameSave(3)”/>
</control>
</panel>
</panel>
<panel id=“spacePanel3” height=“25%” width=“75%” align=“center” childLayout=“horizontal”>
<panel id=“panel31” height=“100%” width=“30%” valign=“center” childLayout=“center”></panel>
<panel id=“panel32” height=“100%” width=“40%” valign=“center” childLayout=“center”></panel>
<panel id=“panel33” height=“100%” width=“30%” valign=“center” childLayout=“center”>
<control name=“button” label=“Back” id=“backButton” height=“50%” width=“100%” align=“center” valign=“center” visibleToMouse=“true” >
<effect>
<onClick name=“playSound” sound=“myclick”/>
</effect>
<interact onClick=“nextScreen(startScreen)”/>
</control>
</panel>
</panel>
</layer>
</screen>
</nifty>
[/java]
[java]
public class Game extends SimpleApplication implements ScreenController, Controller{
…
@Override
public void simpleInitApp() {
System.out.println("simpleInitApp() "+app);
startScreenState = new StartScreenState(app, nifty, screen, popupElement, stateManager);
// startScreenState.myConstructor(this);
startNifty();
bulletAppState = new BulletAppState();
stateManager.attach(bulletAppState);
flyCam.setDragToRotate(true);
// bulletAppState.getPhysicsSpace().enableDebug(assetManager); //shows phyiscs grid
setDisplayFps(false); // to hide the FPS
setDisplayStatView(false); // to hide the statistics
}
private void startNifty(){
niftyDisplay = new NiftyJmeDisplay(assetManager, inputManager, audioRenderer, guiViewPort);
nifty = niftyDisplay.getNifty();
//nifty.fromXml() generates a Nifty Screen out of a XML file
nifty.fromXml(“Interface/screen.xml”, “startScreen”,this);
//guiViewPort.addProcessor shows the nifty predefined object on the display
guiViewPort.addProcessor(niftyDisplay);
//colores the panels of the Nifty Screen, makes it easy to find failures
nifty.setDebugOptionPanelColors(false);
inputManager.setCursorVisible(false);
}
[/java]
Does anyone have an idea why this works on desktop but not on android?
or example code how to use nifty on android would be great !
Greetings from switzerland