[Solved] GotoScreen does not remove the former screen

Hi all!



I’m using a nifty start menu, everything is fine. When I click on a specific button, I call the following method:



[java] public void goToEditShipState()

{

app.getStateManager().attach(new EditShipState());

}[/java]



Which works ok, instantiates a new state, calls the initialize method, which does basically nothing - as in “only initializing a field” - and ends up with a:

[java]this.app.getNiftyDisplay().getNifty().gotoScreen(“EditShip”);[/java]



The said screen is loaded, but over a ghost image of the first screen. (See image below, I’ve move the title on the second screen to show it is indeed duplicated)



http://i.imgur.com/0pAtr.png



I assume it has something to do with my using transparent layers and panels, but I really need that. Here is the full XML below:



[xml]<?xml version=“1.0” encoding=“UTF-8”?>

<nifty xmlns=“http://nifty-gui.sourceforge.net/nifty-1.3.xsd” xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” xsi:schemaLocation=“http://nifty-gui.sourceforge.net/nifty-1.3.xsd”>

<useStyles filename=“nifty-default-styles.xml” />

<useControls filename=“nifty-default-controls.xml” />



<screen id=“start” controller=“business.appstates.MainMenuState”>

<layer id=“background” childLayout=“vertical” backgroundColor="#0000" padding=“25”>



<panel id=“panel_top” height=“25%” width=“100%” childLayout=“horizontal”>

<text text=“Gravity Check” layout=“horizontal” valign=“center” font=“Interface/Fonts/Title.fnt” />

</panel>

<panel childLayout=“vertical” align=“left” width=“20%” height="" padding=“15”>

<text text=“Edit your Ship” layout=“horizontal” font=“Interface/Fonts/Menu.fnt” >

<interact onClick=“goToEditShipState()”/>

</text>



<panel height=“10” />

<text text=“Quit” layout=“horizontal” font=“Interface/Fonts/Menu.fnt” >

<interact onClick=“quitGame()”/>

</text>

<panel height="
" />

</panel>

</layer>

</screen>



<screen id=“EditShip” controller=“business.appstates.EditShipState”>

<layer id=“background” childLayout=“vertical” backgroundColor="#0000" padding=“25”>

<panel id=“panel_top” height=“50%” width=“100%” childLayout=“horizontal” >

<text text=“Gravity Check” layout=“horizontal” valign=“center” font=“Interface/Fonts/Title.fnt” />

</panel>

<panel childLayout=“vertical” align=“left” width=“20%” height="*" padding=“15”>

</panel>

</layer>

</screen>

</nifty>[/xml]



Thanks in advance for any input!

I switch screens all the time and never have this problem. Can you show all your code to load and switch screens. Essentially anything you are doing that interacts with Nifty.

Nevermind, I found the problem while chopping “useless” bits of the code to paste it here.



I did the following - solely for testing purpose, don’t hurt me!! - to add a bloom effect directly on the GUI viewport:

[java] FilterPostProcessor fpp = new FilterPostProcessor(app.getAssetManager());

BloomFilter bloom = new BloomFilter();

bloom.setBlurScale(0.2f);

fpp.addFilter(bloom);

app.getGuiViewPort().addProcessor(fpp);[/java]

and that prevented it from doing a proper refresh.



Thanks anyway!