I have several nifty screens. When nifty.gotoScreen(“screen-name”); is called, the bind() method of that screen controller is called automatically.
I want to initialize something of a screen before it gets visible by calling nifty.gotoScreen(“screen-name”);
When initializing my own things, I need a Nifty object. But the problem is that the screen hasn’t got that Nifty object yet, because the bind method is not called yet. Because the screen is not visible yet.
My situation: I have a loading screen for my game, and I want to show that screen while another screencontroller is filling a list with 300 nifty objects, and loading things from files. This takes a few seconds, and I expect to do all my loading stuff when the loading screen is visible.
I still have a few problems.
I am trying to show a loading screen while another screen gets filled with nifty elements.
For example I have twoo screens: loading-screen and game-hud-screen.
game-hud-screen has a listBox element. I want to fill that listBox with nifty elements, I am doing this with a loop. This process takes about 2 seconds, but there will be more to load in the future. While this loading and element creating process is in progress, I want to show the loading-screen. (Maybe with a progressbar).
I cant get this working. Nifty is always throwing exceptions. Most times my problem is that I never know when the loading process is finished.
It sounds like you could do with a Listener interface. Start the loading screen when you start populating the HUD (and other things). Then let the class that handles the loading notify nifty when it’s done and have it switch screens.
I’ve had some trouble with nifty and loading screens myself. I think it was if the loading is done too quick and gotoScreen is called before the previous screen has been shown (or processed properly). Then I got some kind of deadlock where none of the screens were shown. It was a while, though.
A progress bar is a whole different issue. Settle with something animated for starters. There’s a reason that’s a common thing nowadays.
Still having problems with Nifty.
I’m getting tired of “nifty” gui.
Summary of the problem I always have:
Startscreen. Click on button “singleplayer”.
Switch between appstates, make the loading screen visible.
Load gamedata and populate the hud screen.
Hide the loading screen, switch between appstates, and show the hud screen to start the actual game.
Result I get:
Loading screen doesn’t become visible after clicking “Singleplayer”. The startscreen is still visible.
Loading is in progress while startscreen is still visible.
Loading done, and NOW my loadingscreen becomes visible.
Switching to the hud screen does nothing. The loadingscreen keeps visible.
I think this has to do with the threads of Nifty. So i tried to load my game data within a seperate thread and that worked a little bit, but then I get exceptions: