Thanks for reply, unfortunately no joy, I have updated and tried what you said but to no avail
The xml is being read as I can see that in the console, I call it using…
[java]
niftyDisplay = new NiftyJmeDisplay(assetManager, inputManager, audioRenderer, guiViewPort);
/** Create a new NiftyGUI object /
nifty = niftyDisplay.getNifty();
/* Read your XML and initialize your custom ScreenController */
nifty.fromXml(“Interface/menuscreen.xml”, “start”, new MenuScreenController());
// attach the Nifty display to the gui view port as a processor
guiViewPort.addProcessor(niftyDisplay);
[/java]
and the rest of it is above, I cannot see why this wouldn’t be working, it is such an easy example, one of the simplest lol and I can’t get it to behave
Everything works except the screen controller, I get no printlns occur for any of the methods bind(), onStartScreen(), onEndScreen(), buttonSinglePlayer(). My conclusion can only be that I am not initialising the class MenuScreenController correctly but I do not know why.
I can see the gui and it pulsates when I mouse over it but the onClick doesn’t work because I believe it cannot see the buttonSinglePlayer() method or anything in fact in the MenuScreenController class. Hmmmz Why might this be?
Below is part of the data in the console, you can see in bold where it initialises the screen controllers, the screen=“end” doesn’t have a controller so this is what I would expect to see if the screen controller was not found. But it seems to be able to find MenuScreenController, I don’t know what @19bfb30 means though 8O
I can run the TestNiftyGui test which has a onClick event and it works propperly so think that it is definately something that I am doing wrong lol but I cannot see what, there must be more to it, I’ll stick at it I suppose lol
Ok so I have been playing around with this still and basically I am still confused but I have made progress.
Basically my project is set up so that I have AppStates that each create a GUI and then destroy it and themselves before initialising a new AppState. Here is an example of one of my AppStates…
public class SplashScreen extends AbstractAppState implements ActionListener, AnalogListener {
Application application;
AssetManager assetManager;
InputManager inputManager;
AudioRenderer audioRenderer;
ViewPort guiViewPort;
AppStateManager appStateManager;
ClientMain clientMain;
NiftyJmeDisplay niftyDisplay;
Nifty nifty;
String[] mappings;
public SplashScreen(ClientMain app) {
clientMain = app;
}
@Override
public void initialize(AppStateManager stateManager, Application app) {
application = app;
appStateManager = stateManager;
assetManager = application.getAssetManager();
inputManager = application.getInputManager();
audioRenderer = application.getAudioRenderer();
guiViewPort = application.getGuiViewPort();
initialized = true;
niftyDisplay = new NiftyJmeDisplay(assetManager, inputManager, audioRenderer, guiViewPort);
nifty = niftyDisplay.getNifty();
nifty.fromXml("Interface/splashscreen.xml", "start", new SplashScreenController());
guiViewPort.addProcessor(niftyDisplay);
if (inputManager != null) {
registerWithInput(inputManager);
}
}
public void registerWithInput(InputManager inputManager) {
mappings = new String[]{
"MOUSE_BUTTON_LEFT",
"ESCAPE"
};
inputManager.addListener(this, mappings);
}
public void onAction(String name, boolean isPressed, float tpf) {
if (name.equals("MOUSE_BUTTON_LEFT") && isPressed){
clientMain.deactivateSplashScreen();
clientMain.activateLoginScreen();
} else if (name.equals("ESCAPE") && isPressed) {
clientMain.deactivateSplashScreen();
clientMain.activateLoginScreen();
}
}
public void onAnalog(String name, float value, float tpf) {
}
@Override
public void update(float tpf) {
}
@Override
public void cleanup() {
// cleanup
initialized = false;
inputManager.removeListener(this);
guiViewPort.removeProcessor(niftyDisplay);
// destroy variables
application = null;
assetManager = null;
inputManager = null;
audioRenderer = null;
guiViewPort = null;
niftyDisplay = null;
nifty = null;
mappings = null;
}
}
[/java]
I have three App States in total at the moment, the a SplashScreen a LoginScreen and a MenuScreen each with their respective ScreenControllers and nifty .xml file.
I changed the above SplashScreen class so that it used the MenuScreenController() and menuscreen.xml and low and behold it worked on the splash screen, I was able to see clicks outputting strings to the console!!! I changed to the LoginScreen which is just a box with no interact tag and it looked ok… but I clicked the box… and it outputted strings to the console!!! It is not supposed to, so I think that the initial ScreenController still lived!!! OH NO!!! So I think that this may be the problem!
I then went to the last screen and it worked but I think that it was still the first ScreenController that was in action. I thought that I was killing the NiftyGui in the cleanup() method but maybe not?!?!?!
In your earlier problem, aside from the event clicking and the colored boxes, could the label/texts/images be displayed finely at that time? Because I'm having this issue now after testing about and searching around but no answers to my problems yet.