Understanding jME3 AppStates

I posted over in the BulletAppState post about learning AppStates and did some research. Haven’t dug in yet, but I just wanted to get some things clarified since there doesn’t seem to be much in the way of explaining the what’s and how’s of AppStates. - Yeah there’s a test case, but it doesn’t tell me too terribly much other than one usage.

So, as for game structure. Let’s say it starts up as:

Main (Application) + GameView (AppState) + MenuView (AppState)

Where, the application is just ‘controlling’ and the GameView would currently be a black void (Scary!), and the MenuView would be the main menu with things such as “New Game,” “Options,” “Exit,” etc etc. Concentrating on getting a game running, let’s pick “New Game:”

Main (Application) + GameView (AppState) + LoadingState (AppState)

Now, with the menu detached and out of the view, the game loads in another state with some fancy loading screen (Probably some fancy transition effects as well, polish for later though). Once all the initial game related assets are ready to go, it transitions to a simpler:

Main (Application) + GameView (AppState)

Where the game will presumably start up. And at any time, let’s say the player can smack the ESC key or something to bring up the menu (and pause the GameView State?).

  1. Is this the basic idea of how AppStates are envisioned to be used?

  2. GameView would actually be a BulletAppState if we were using physics correct? Or would it be an AppState CONTAINING a BulletAppState? (Whoa) o_o

  3. Gotta use the standard “Application” class for AppStates right? I’ve noticed every bit of example I can find on using these are all using Application instead of SimpleApplication.

  4. Everybody touches the same inputmanager from Application right? They just add listeners when appropriate?

    Whew. I think that’s all I got. Sorry if I got a bit long winded.

    Thanks for reading!

1 Like

AppStates are just a list of classes that are called on specific events (update, render etc) and you can add or remove them from the render loop. Nothing more. So instead of writing every new function of your game into the update() and render() loops of your SimpleApplication (which is working with AppStates and is in fact the only class that calls the AppStateManager automatically at the appropriate times) you simply create AppStates that have the code in their update methods. So what you do with them is completely up to you. The examples show how you can use it for a NiftyGUIAppState and the BulletAppState is an example how you can wrap a whole PhysicsSpace into an AppState.