Hi,
My game is using nifty and zay-es. When I run the game on PC it works fine but when I run it on android, it takes long to display the very first nifty screen.
- Is there any way to display loading screen for the first nifty startScreen so that it doesnt simply display black screen.
After navigating a bit in nifty screens, I eventually move to hudScreen and load the scene graph. Now when the transition happens, it again takes some time to display models and again simply shows the old nifty screen. I try to put a wait screen in there but it does not immediately displays that screen and instead stucks until the scene graph is loaded.
- is there any way to display that wait screen
Another way that I tried is using loading screens but its popping a exception ‘Java.illegalStateException: screengraph not properly updated for rendering’.
Here is the code that I’m using
[java] public void startGame(){
System.out.println(“Starting GAME”);
confirmed = false;
de.lessvoid.nifty.elements.Element niftyElement = nifty.getScreen(“hudScreen”).findElementByName(“confirmedStatus”);
niftyElement.getRenderer(TextRenderer.class).setText(“Not Confirmed!!”);
System.out.println("Hello Hello!!");
//app.getFlyByCamera().setDragToRotate(false);
//nifty.gotoScreen("hudScreen");
load = true;
// Loading screen
rgas.reInitialize(time);
setProgress(0.25f , "Loading: 25%");
//update(2000);
//try {
// Thread.sleep(500);
//}
//catch (Exception e) {
//}
//setProgress(1 , "Loading: 100%");
}
//this is the callable that contains the code that is run on the other thread.
//since the assetmananger is threadsafe, it can be used to load data from any thread
//we do *not* attach the objects to the rootNode here!
Callable<Void> loadingCallable = new Callable<Void>() {
public Void call() {
System.out.println("\n\n\n\n\nmonkey **************************");
de.lessvoid.nifty.elements.Element element = nifty.getScreen("loadlevel").findElementByName("loadingtext");
textRenderer = element.getRenderer(TextRenderer.class);
nifty.gotoScreen("loadlevel");
progressBarElement = nifty.getScreen("loadlevel").findElementByName("progressbar");
setProgress(0 , "Loading: 0%");
/*
* These reInitialize methods has been defined because some appStates
* require some fresh objects or parameters which cant be passed from
* OVERRIDDEN setEnabled(). This can be fixed with some better design
* by probably moving some code around or making new appstates for
* fresh objects..
*/
setProgress(0.25f , "Loading: 25%");
eds.reInitialize();
setProgress(0.50f , "Loading: 50%");
ppes.reInitialize();
setProgress(0.75f , "Loading: 75%");
mes.reInitialize(new XMLModelFactory(qId));
setProgress(1 , "Loading: 100%");
return null;
}
};
@Override
public void update(float tpf) {
//do the following while game is running
if (load) {
if (loadFuture == null) {
//if we have not started loading yet, submit the Callable to the executor
loadFuture = exec.submit(loadingCallable);
}
//check if the execution on the other thread is done
else if (loadFuture.isDone()) {
//these calls have to be done on the update loop thread,
//especially attaching the terrain to the rootNode
//after it is attached, it’s managed by the update loop thread
// and may not be modified from any other thread anymore!
//nifty.gotoScreen(“end”);
//nifty.exit();
//guiViewPort.removeProcessor(niftyDisplay);
//flyCam.setEnabled(true);
//flyCam.setMoveSpeed(50);
System.out.println("\n\nLOADED");
nifty.gotoScreen(“hudScreen”);
//rootNode.attachChild(terrain);
load = false;
}
}
} [/java]
The flow starts from startGame(). I have read that its because that I’m modifying scenegraph. When I attaches the appStates it loads models and scene(but scenegraph nodes etc remain static) which according to my best knowledge is the culprit for slow loading. How should I try to approach the problem. My concern is simply to avoid and blank and stuck screens…