@pspeed said:
Not really. It was the equivalent of running a program on someone else's computer and having it fix a problem on yours. I hope nothing stranger than that has ever happened to you.
Since you are kind of new-ish to Java, I will offer some debugging advice.
First:
MyAppState state = stateManager.getState(MyAppState.class);
…where “MyAppState” is the exact class of your app state. Not AppState… but your class name.
Second:
System.out.println(“State:” + state);
Then:
stateManger.detach(state);
…if this doesn’t detach the state then you are testing to see if the state is detached incorrectly or you have multiple states attached of the same class… in which case you can try getState(MyAppState.class) + println again to see if that’s true.
But if there is only one state and detach seems not to detach it… then your method of detection of what is detached is busted.
Well… There was this one time in Computer Camp…
Okay so one of my examples was, again stateManager.getState(StartScreenAppState.class);
using this method this.stateManager.detach(stateManager.getState(StartScreenAppState.class));
I didn’t debug on this one method (since it did what the others did), so I see now my approach was correct, but something isn’t getting removed.
inside my AppState I do.
[java]gui.addControl(screen);
//screen.initialize();
Window panel = new Window(screen, new Vector2f(0,0), new Vector2f(settings.getWidth(), settings.getHeight()));
//screen.addElement(panel);
panel.setIsMovable(false);
panel.setIsResizable(false);
screen.addElement(panel);
ButtonAdapter openP = new ButtonAdapter(screen, new Vector2f((settings.getWidth()/2f), settings.getHeight() * 0.45f))
{
@Override
public void onButtonMouseLeftUp(MouseButtonEvent evt, boolean toggled)
{
openPlan();
}
};
openP.setPosition(openP.getPosition().x-openP.getWidth()/2f, openP.getPosition().y);
openP.setText("Open Plan");
panel.addChild(openP);
}[/java]
Then for the cleanup which is where the problem lies
[java] @Override
public void cleanup() {
super.cleanup();
gui.removeControl(screen);
//TODO: clean up what you initialized in the initialize method,
//e.g. remove all spatials from rootNode
//this is called on the OpenGL thread after the AppState has been detached
}[/java]
From checking the debugger the screen is being removed, so something else must be hanging around…?
Also Pspeed, no need to treat me like a noob, nor are the comments needed, just because I posted something you don’t approve of.
I didn’t make myself clear when I said AppState.class or new AppState, as I meant my own AppState class (StartScreenAppState), and not something else.
I guess I should have looked at my last approach more before posting, since I obviously caused a bit of confusion, but at least I’m on the right path to figuring this out.
I do appreciate your help regardless, as well as everyone else’s.
Thank you.
EDIT: So I needed to call gui.detachAllChildren(); Just this will remove my start menu; however I need to ask about the t0neG0dGUIScreen. It is still attached if I remove all the children, but the question is.
-
Should I remove the screen still?
-
The Screen is where all of my buttons are added it seems (in this case I only posted one), so why does nothing happen when it’s removed (Is it because the window is added to the gui node hierarchy separate from the Screen)?
[java]
gui.addControl(screen);
screen.addElement(panel);
panel.addChild(register);
panel.addChild(openP);
panel.addChild(options);
panel.addChild(about);
panel.addChild(exit);[/java]
It’s weird because there is a single node under “gui,” and from there 5 additional nodes. 3 are “AudioNodes” (stopped), 1 is the background, and then comes the window, which is what I want.
Thanks