I’ve begun integrating GUIs into my game, and once I’ve figured out if I’ll be going with Feng or GBUI, I’d like to start putting some stuff into GameStates so I can have a loading screen etc.

I’ve done some reading, and the way I understand it is that a GameState has it’s own init, update, and render methods. You break your game apart into several GameStates (i.e. the Menu render wouldn’t renderupdate the character, etc.) and then in your main game you set them as enabled / disabled.

Is this true? Is there any reading other than this?

From that tut, it seems as if you have to add everything to the Game States’ nodes and then set them as running or not running, can I simply extend GameState three times (for three different states), create those states in my main game, and set them as enabled or disabled?

What’s the best way for going about this?

Just a bit more info, this is what I’m hoping to accomplish:

-loading screen

-full-screen menu

-full-screen map

-actual game

-(later)login screen

-(later)character selection screen

The first 3 can be done before all of the networking stuff is operational, so what should I do ?

The way i'm currently doing this is by extending the gamestate of your choice, so you would indeed have 3 separate classes extend a gamestate. I also give them unique names so i can call them by name from the gamestate manager from other states and enable/disable them depending on user actions.

This seems to be working well for me.


i do it like Hellmaster, until now i only had like 3 GameStates so its not a problem to enable/disable them individually.

I guess as your game gets more complex maybe it can be convenient to organize them i a tree structure.

So I was correct in thinking each one has it's own init, update, and render methods that I put stuff into, and it takes care of the treading when I set it to enabled?

a gamestate has its own init update/render part yes, but it has nothing to do with threading.

The GameStateManager simply calls the update/render Methods of the active GameStates.

Are there any examples (other than the thread above)? Could you show me a bit of random source from your game to get me started? Or explain how I could do like a red box GameState and a BlueSphere GameState? I understand I'll have to extend the classes, but which one should I extend, and how do I put it in the main part of the game?

well there is a small wiki entry about a FengGUI GameState which could get you going.

Or you can look at one of the open source jme games and see how they do it:

monkey-mahjongg or physics fun

Its best if you grab the source via svn and see how they do it, thats what they are there for :slight_smile:

And keep in mind, that there is no right or wrong way to do something, just many different ones.

You’re right, but the way I wanted wasn’t in either of those Wikis…

So I did the good-guy thing and made a new one.

Tell me what you think.

I know nothing about GameStates, but as a tutorial it looks very nice. Keep up the good work!

Nice tutorial. Personally I find subclassing BasicGameState easier as all abstract methods are implemented and a root node is created for you.

Extending GameState gives you a lot more control, that's the only reason I did it that way  :smiley:

Tutorial looks nice! Good job! :slight_smile:

I generally use GameStates to enforce a strict hierarchy between the abstract parts such as GUI, Game, Menu etc. and I think that is where the strenght lies.

If you've worked with jME before GameStates and made a somewhat big game, it eventually became a mess…