Adding GameStates to testIsland?

I'm new at JME, and I've been messing around with testIsland. I've added quite a few things already to just to experiment and learn things… but now I want to add some simple menus. If I understand correctly, I have to utilize GameStates to do this. But how? I'm extending SimplePassGame already, it seems like I'd have to extend GameState  :expressionless:



Any hints?

You will want to use StandardGame and not BaseSimpleGame. You can probably copy/paste most of the test island code into a GameState you create. And yes you will have to extend GameState. Then you can use StandardGame to create your game states.

I don't have my code here, but to do it do something like this:



Create your StandardGame. Call start() on it. Then create your game state and add it to the GameStateManager:



MainGameState currentGameState = new MainGameState();

// add all the test island init and update/render code to it.

// initialize it

GameStateManager.getInstance().attachChild(currentGameState);

currentGameState.setActive(true);



GuiGameState myGuiGameState = new GuiGameState();

GameStateManager.getInstance().attachChild(myGuiGameState );

myGuiGameState.setActive(true);



and that should be it. Both game states will get their update() and render() methods called, which is where you will do most of your stuff. Just create your UI in the constructor or in a separate init method.



You UI does not have to be in a separate game state. You can throw the code in your current game, it just might get a little unwieldy.

you can use gamestates also with simplepassgame, just create a GameStateManager instance and update/render it in a pass.

Alright guys, thanks for the help!

I'll play with this and see if I can figure it out  :smiley: