Can't load nifty

Because I am at the point where I need an hud for my game I decided to look at the JME tutorial in regards to nifty. However, I am already getting stuck at https://jmonkeyengine.github.io/wiki/jme3/advanced/nifty_gui_overlay.html

The current issue that I have is the first piece of code

NiftyJmeDisplay niftyDisplay = new NiftyJmeDisplay(assetManager, inputManager, audioRenderer, viewPort);
Nifty nifty = niftyDisplay.getNifty();

This already errors and gives me “cannot find symbol” which most likely means that I need to import something. However, the editor that I use (The SDK from monkeyengine) for the first time can’t tell me what to import and unless I read over it its not on that page either.

Also that page has a link to Google Code Archive - Long-term storage for Google Code Project Hosting. for sample code to get this working but I fear that that link needs to get updated as it now goes to a pretty empty google code page.

Any pointers are welcome especially as I am pretty sure its more user error than anything else.

May the lemur be with you.

In the main file you should have.

@Override
public void simpleInitApp() {

	NiftyScreen niftyScreen = new NiftyScreen();
	stateManager.attach(niftyScreen);
	
}

Next, create a file named NiftyScreen.java and paste your code.

		NiftyJmeDisplay niftyDisplay = new NiftyJmeDisplay(assetManager, inputManager, audioRenderer, guiViewPort);
		Nifty nifty = niftyDisplay.getNifty();
		nifty.registerScreenController(this);
		guiViewPort.addProcessor(niftyDisplay);

I use Nifty, so I know it’s still practical to do so.

Which symbol was not found?

It seems like the nifty library has not been added to your project. Right click your project, go to properties and under libraries you have to click “Add library” and import “jme3-niftygui”.

2 Likes

Yep, that was it. I guess it doesn’t get added by default then?

Oh well, I think I can make the rest work by myself.

Is there a way to edit the docs to mention that it doesn’t always get added when you make a project and how to do it?

edit: added a quote to the post that helped me

Sure, you can edit the wiki yourself. Here you go, (then) you made jME a little better :slight_smile:

And note: by default, JME will include a minimal amount of stuff that everyone might need. So often for advanced or less-used things then you will have to add the libraries yourself. Else people would have a lot of junk included in their projects that they weren’t even using. (Which is already kind of true with the default configuration.)

Nifty is one of three different GUI libraries one might use now… so even if the distribution were even (which it isn’t), of the percentage of games that actually need a GUI beyond a text label here and there, nifty would only be used by 1/3rd of those. So overall, much less than 33%… which doesn’t warrant including it by default in all basic game projects.

That makes a lot of sense actually. Though, I expected Nifty to be one of those things that would be included by default but if there are indeed many other things that people use it makes sense if it isn’t. Though that is even more reason the docs should probably mention that you need to enable it yourself.

Definitely.

Just saw this thread.

I am almost finished with AI and GUI is next for me. I fixed the link and added the info on installing the library anyway.

I will go over the rest sometime in the near future unless other problems need immediate attention.

1 Like