I have a jME3 program that starts a main SimpleApplication that sets up Nifty:
[java]
@Override
public void simpleInitApp() {
blankState = new BlankState(this);
graphicsState = new GraphicsState(this);
loggerRunning = false;
// Setup the GUI
NiftyJmeDisplay niftyDisplay = new NiftyJmeDisplay(assetManager,
inputManager,
audioRenderer,
guiViewPort);
nifty = niftyDisplay.getNifty();
nifty.fromXml("Interface/settingsScreens.xml", "connection", this);
nifty.addXml("Interface/graphicsScreen.xml");
guiViewPort.addProcessor(niftyDisplay);
inputManager.setCursorVisible(true);
System.out.println("Initialized Main");
stateManager.attach(blankState);
[/java]
BlankState and GraphicsState are classes that extend AbstractAppState. Using this method, everything works when I want to “print” values to labels in my GUI. What I am getting hung up on is how to correctly call functions when buttons are pressed in my GUI. I have tried to implement the ideas presented in the following wiki article:
https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:nifty_gui_java_interaction
I have a class in my created Android project (the one located in the newly created mobile folder) called ReadLocationState:
[java]public class ReadLocationState extends AbstractAppState implements ScreenController { stuff }[/java]
This class implements bind, onStartScreen, and onEndScreen and then has a method checkConnections() to be called when the Check Connections button is pressed in the Nifty GUI. My problem is I don’t think I am correctly connecting my Nifty XML files to this class. I have tried both:
[java]
<screen id=“graphics” controller=“edu.pworm.mocap.ReadLocationState”>
[/java]
and
[java]
<screen id=“graphics” controller=“mobile.src.edu.pworm.mocap.ReadLocationState”>
[/java]
and neither one seems to register the button correctly. Am I going about this the wrong way? I can’t implement these buttons on the “jME3 program side” because when these buttons are pushed, I need to call Android specific functions. How is this normally done?
P-Worm