General AppState questions

After programming several games, and attempting at a more complex game, I encountered certain problems, at which point I decided that it was time to look at AppStates, CustomControls, and multi-threading. So far I’ve only looked at appstates, and I have a few questions:


  1. How do I pass an instance of main (and variables) to the AppState when it’s initalized.

    I tried this by adding them to the beginning of the method where you define the variables it recieves, but at “stateManager.attach(myAppState);”

    I couldn’t figure out how to send the variables.


  2. Once I’ve done “app.getState(MyAppState.class).setSomething(blah);” does the value magically change, or do I have to call somthing in the

    AppState and tell it to recieve the variable?
    I did some more messing with it, and only managed to confuse myself even more : how do I

    even use the above command? It lets me send something like a node, but I can’t figure out how to obtain the node within the AppState.


  3. Am I right in thinking that the AppState is to manage methods that would take up lots of time, freeing up game time, and clearing up lag (similar to

    multi-threading)
  1. you do it when you create the app state not when you attach it.


  2. these are methods YOU write… they can do whatever you want. setSomething(blah) would be written to do something with “blah” like set it to a field local to your app state.


  3. No. They are a way of breaking down your application into logical components.



    The first two questions having nothing to do with app states really and are more general Java questions. There really isn’t any magic going on.



    I strongly recommend that you run through some basic Java tutorials before attempting 3D game development.

I have been running through basic java tutorials, and have been making quite a bit of headway, and thanks for answering my question, I think that I now understand what I need to understand about AppStates.