@glaucomardano I changed my id’s in the nift files so that all id’s are unique:
nifty1.xml
[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”>
<!-- +++++++++++++++++++++++++++++++++++++++ -->
<!-- start screen -->
<!-- +++++++++++++++++++++++++++++++++++++++ -->
<screen id=“start1” controller=“mygame.Main”>
<layer id=“layer1” backgroundColor="#003f" childLayout=“center”>
<panel id=“panel1” height=“25%” width=“35%” align=“center” valign=“center” backgroundColor="#f60f" childLayout=“center” visibleToMouse=“true”>
<interact onClick=“nifty1()”/>
<effect>
<onStartScreen name=“move” mode=“in” direction=“top” length=“300” startDelay=“0” inherit=“true”/>
<onEndScreen name=“move” mode=“out” direction=“bottom” length=“300” startDelay=“0” inherit=“true”/>
<onHover name=“pulsate” scaleFactor=“0.008” startColor="#f600" endColor="#ffff" post=“true”/>
</effect>
<text id=“text1” font=“aurulent-sans-17.fnt” color="#000f" text=“NIFTY1” align=“center” valign=“center” />
</panel>
</layer>
</screen>
</nifty>
[/xml]
nifty2.xml
[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”>
<!-- +++++++++++++++++++++++++++++++++++++++ -->
<!-- start screen -->
<!-- +++++++++++++++++++++++++++++++++++++++ -->
<screen id=“start2” controller=“mygame.Main”>
<layer id=“layer2” backgroundColor="#003f" childLayout=“center”>
<panel id=“panel2” height=“25%” width=“35%” align=“center” valign=“center” backgroundColor="#f60f" childLayout=“center” visibleToMouse=“true”>
<interact onClick=“nifty2()”/>
<effect>
<onStartScreen name=“move” mode=“in” direction=“top” length=“300” startDelay=“0” inherit=“true”/>
<onEndScreen name=“move” mode=“out” direction=“bottom” length=“300” startDelay=“0” inherit=“true”/>
<onHover name=“pulsate” scaleFactor=“0.008” startColor="#f600" endColor="#ffff" post=“true”/>
</effect>
<text id=“text2” font=“aurulent-sans-17.fnt” color="#000f" text=“NIFTY2” align=“center” valign=“center” />
</panel>
</layer>
</screen>
</nifty>
[/xml]
And also changed the nifty initialization code from
[java]
niftyDisplay.getNifty().fromXml(“Interface/nifty1.xml”, “start”, main);
[/java]
to
[java]
//in NiftyState1 class
niftyDisplay.getNifty().fromXml(“Interface/nifty1.xml”, “start1”, main);
//in NiftyState2 class
niftyDisplay.getNifty().fromXml(“Interface/nifty2.xml”, “start2”, main);
[/java]
But I’m, getting the same result.
I’m extending Application instead of SimpleApplication because there are many things extra in SimpleApplication I don’t need in my game (the attached main is based on my current project’s) and most of the code is the same as SimpleApplication (which extends Application) but removing extras (flyCam, debug info and so on). Anyway, I’ve changed it to extend SimpleApplication and tried having also the same results. This is the new code for main.java:
[java]
package mygame;
import com.jme3.app.SimpleApplication;
import de.lessvoid.nifty.Nifty;
import de.lessvoid.nifty.screen.Screen;
import de.lessvoid.nifty.screen.ScreenController;
import java.util.logging.Level;
import java.util.logging.Logger;
public class Main extends SimpleApplication implements ScreenController
{
NiftyState1 nifty1;
NiftyState2 nifty2;
public static void main(String[] args)
{
Main app = new Main();
app.start();
}
@Override
public void simpleInitApp()
{
//I want to see my mouse
flyCam.setDragToRotate(true);
//Disable clear in the default viewport in the app
this.viewPort.setClearFlags(false,false,false);
this.guiViewPort.setClearFlags(false, false, false);
nifty1=new NiftyState1(this,this.settings);
nifty2=new NiftyState2(this,this.settings);
//Only activate nifty1
nifty1.activateState();
}
public void bind(Nifty nifty, Screen screen) {
}
public void onStartScreen() {
}
public void onEndScreen() {
}
/**
- Callback from nifty1 screen
*
- Deactivates nifty1 and activates nifty2
*/
public void nifty1()
{
Logger.getLogger("").log(Level.WARNING, "Nifty1 callback - changing to nifty2 screen");
nifty1.deactivateState();
nifty2.activateState();
}
/**
- Callback from nifty2 screen
*
- Deactivates nifty2 and activates nifty1
*/
public void nifty2()
{
Logger.getLogger("").log(Level.WARNING, "Nifty2 callback - changing to nifty1 screen");
nifty2.deactivateState();
nifty1.activateState();
}
}
[/java]