I can’t find a function to just clear a whole screen object from all its children.
When i want to switch from one kind of gui (like a login screen) to another (like ingame screen) i allways have to put the root elements on the screen in variables and use the screen.removeElement() to remove them and put the new gui on the screen.
Just removing the whole screen from the guinode and creating a new one causes an exception, so i guess you need to reuse the screen object for all your guis.
Maybe i am doing something wrong here, but i was expecting something like screen.clear() or screen.removeAllElements().
Hello,
I am not an expert, but run in similar problems. In my application, I create a new screen after resiziing of the window. Here I get an exception in the screen constructor. My workaround inserts a try-catch and looks as follows, but I am bot sure if that helps you:
[java] public Screen(Application app, String styleMap) {
this.app = app;
this.elementZOrderRay.setDirection(Vector3f.UNIT_Z);
try { // TODO
app.getAssetManager().unregisterLoader(BitmapFontLoader.class);
app.getAssetManager().registerLoader(BitmapFontLoaderX.class, “fnt”);
}
catch (Exception e) {}
this.styleMap = styleMap;
parseStyles(styleMap);
effectManager = new EffectManager(this);
app.getInputManager().addRawInputListener(this);
layoutParser = new LayoutParser(this);
}
[/java]