State detach problem

hi, im trying to detach a state by pressing a NiftyGUI button:



[java]

public void setDrawTexture0(){

this.app.getStateManager().detach(edit);

System.out.println(“detached”);

}

[/java]

its prints out “detached” but doens’t remove the state. This happens in NiftyGUI and Listener functions.



Anybody know why that is? How do i remove States by pressing a button?



greetings

droillian

I’d need to know a lot more.



If you are running the latest stable update after beta then it’s likely something strange like that your state is really attached more than once or something. How are you verifying that the state hasn’t been removed?



And I suppose I should also check to see if you are properly extending SimpleApplication or if you’ve done things the hard way and extended Application directly.

1 Like
How are you verifying that the state hasn’t been removed?

If i attach the state i see a spatial on the scene. If i detach it in the same or another function in the same class everything works fine. Its just not working for the ActionListener and the Nifty functions. The spatial and all its functions stays on the scene. Im attaching it only once by now.

And I suppose I should also check to see if you are properly extending SimpleApplication or if you’ve done things the hard way and extended Application directly.

Im extending SimpleApplication and my AbstractAppStates are getting their SimpleApplications like this
[java]
//..
private SimpleApplication app;
//..
public void initialize(AppStateManager stateManager, Application app) {
super.initialize(stateManager, app);
this.app = (SimpleApplication) app;
//..
[/java]

Edit: Attaching states via NiftyGUI does work. Just detaching doesnt work.

What version of JME are you using? Alpha 4? Beta? Beta+stable updates? (hopefully the last one)

Also, the only real way to know if you are being detached is to log or system.out.println in the state’s stateDetached() method. Your “I no longer see X” approach has too many other things that can go wrong… since I don’t know how you are removing/disabling the stuff that you expect not to see when the state is detached.



Also, do you remove these things in stateDetached() or in cleanup()? cleanup() would be another one to log/println.

1 Like
@pspeed said:
What version of JME are you using? Alpha 4? Beta? Beta+stable updates? (hopefully the last one)

Im using the sdk and the auto update function it has. In tools->plugins->settins i've marked jmonkeyengine as active and it says there
Last Check: 3/10/12 2:18 PM
URL: http://jmonkeyengine.googlecode.com/svn/trunk/

If this is the correct way to keep everything up to date i guess everything is up to date.

...when im starting my project it says:
run:
Mrz 10, 2012 2:23:09 PM com.jme3.system.JmeDesktopSystem initialize
INFO: Running on jMonkeyEngine 3.0.0 Beta

Well if thats wrong, how do i update the jmonkey engine? Please dont just say i have get the latest versions via svn/cvs because i have no clue what to do with them (ive never worked with svn/cvs on my own). Maybe there is a readme somewhere on how to keep everything up to date?

Also your stateDetached() hint leaded me to the error, seems like i've implemented something not correctly. Now evething works fine. If the Forum would have a tip-system i'd just give you a dollar :)

Thanks a lot.

Glad you got it working.



The 3.0.0 beta indicates that you have not updated to the latest stable. The SDK is already setup to update to stable automatically but you have to let it. If you go to Tools → Plugins, it’s probably telling you there are things it wants to update.

Yes, the SDK is up to date. But how do i update the jmonkey engine itself?

@drollian said:
Yes, the SDK is up to date. But how do i update the jmonkey engine itself?


When you go Tools -> Plugins -> Update it verifies updates for the lastest version of the jME3. Just to make sure, go to the Settings panel and make sure jMonkeyEngine SDK Stable is checked.
@shirkit said:
When you go Tools -> Plugins -> Update it verifies updates for the lastest version of the jME3. Just to make sure, go to the Settings panel and make sure jMonkeyEngine SDK Stable is checked.

Ah ok, because ive done that and when im creating a new test project and run a test its says:

compile-single:
run-single:
Mrz 11, 2012 4:30:51 AM com.jme3.system.JmeDesktopSystem initialize
INFO: Running on jMonkeyEngine 3.0.0 Beta

Current version is: 3.0.0.9083