Nifty: Is there a better way to stop onStartScreen effects?

I wanted the user to be able to press space to skip the fade in etc. and just show the screen (or just skip the page all together)

So what I tried to do was this:


for (Element layerElement : screen.getLayerElements()) {




But what happens then is that the screen never gets to know the effects are done. So when you try to goto a new page you get this error:

INFO: gotoScreen [mainMenu] aborted because still in gotoScreenInProgress phase

What I ended up doing was this:


Class<? extends Nifty> aClass = nifty.getClass();

Field field = aClass.getDeclaredField(“gotoScreenInProgess”);


field.set(nifty, false);


Not very pretty. The other alternative I thought of was to fiddle with the “startTime” of the TimeInterpolator instances in the effects. That could be more powerful because then I could do something like “speed up” the effects when the user presses a key but also more of the same reflection magic. Not very clean. Is there a better way to do that?

Why didn’t you stop the fade-in effect one instead of stopping the onStartScreen one?

Unless I’m mistaken this code stops all “onStartScreen” effects attached to a specific element. This could be “fade”, “move”, “colorChange” or any effect. so “onStartScreen” isn’t a effect. It’s a event that triggered any number of effects. and the stopEffect call stops all effects started by it.

And that part of the code works. The screen goes into how it would look after all effects had completed. It’s just that when I call the method to goto the next page I get that error.