Hi t0neg0d, I’m having a bit of trouble when switching app states. When the other app state appears (game state) the main menu gui is not being removed. I don’t know if I’m doing this right, anyways heres the code for my menu app state (its really simple for now):
[java]
package frost;
import com.jme3.app.Application;
import com.jme3.app.state.AbstractAppState;
import com.jme3.app.state.AppStateManager;
import com.jme3.input.event.MouseButtonEvent;
import com.jme3.math.Vector2f;
import tonegod.gui.controls.buttons.ButtonAdapter;
import tonegod.gui.core.Screen;
/**
*
-
@author Davis
*/
public class StateMenu extends AbstractAppState {GameMain app;
Screen screen;ButtonAdapter start;
@Override
public void initialize(AppStateManager stateManager, Application app) {
super.initialize(stateManager, app);
this.app = (GameMain)app;
screen = new Screen(this.app, “tonegod/gui/style/atlasdef/style_map.xml”);
screen.setUseTextureAtlas(true, “tonegod/gui/style/atlasdef/atlas.png”);
this.app.getGuiNode().addControl(screen);start = new ButtonAdapter(screen, new Vector2f(60 ,20) ) { @Override public void onButtonMouseLeftUp(MouseButtonEvent evt, boolean toggled) { clickedStart(); } }; screen.addElement(start);
}
@Override
public void update(float tpf) {}
@Override
public void cleanup() {
super.cleanup();
this.app.getGuiNode().removeControl(screen);
app.getRootNode().detachAllChildren();
}public void clickedStart() {
app.getStateManager().attach(new StateGameplay());
app.getStateManager().detach(this);
}
}
[/java]
Also, is there any way to stop the space bar auto tab element thing? I don’t have a need for that.