GameStates BasicGameState GameStateNode BasicGameStateNode?

Hello!  :smiley:

(I step forward to say that I am not a good english talker) :frowning:

I read this last hour the Javadoc, about GameState, really im confused with the descriptions.  :?

I dont know the difference about GameState likes classes, i understand… :


This have abstracts methods as: update(float) and render(float), and a parent state will call this methods.


This say that implement the abstract update and render of GameState, but, with WHAT IMPLEMENTANTION CODE HAVE THIS? null? also i understand that create a rootNode empty for add jme nodes to this scene. true?


This also can be a PARENT, can attach childs GameStates and other GamesStatesNodes for complex trees (But NOT BasicGameState and BasicGameStateNode). Calling update() or render() this call the same method in the childrens.


This also can be a parent, but ONLY for BasicGameState or BasicGameStateNode, (NOT for GameStates and GameStateNode)

but… WHAT DIFFERENCE have with GameStateNode? also follow calling update and render to the childs no? what difference have then?


Fantastic engine, atleast by now! hehe

Those classes are meant to be extended for what your personally needs are :wink:





GameStateNode            BasicGameState




The 'basic' classes have 'stuff' implemented in them for you already (generic stuff that is likely to be needed).  While the 'non-basic' stuff is the 'bare-bones', no frills version.

(also, I think your assumptions on how you can attach the GameStateNodes is a little off; I believe that any GameState can be added to any GameStateNode…)

…pretty sure I wrote a wiki article relating to this many moons ago.

sho’ 'nough:

Yes Darkfrog this article is one of my first docs with jMonkeyEngine.

Is cool, but one suggest, your examples is too more understandable write the gamestate stuff into other class extending of GameState.

But now i have a question.

I have this classes




              |-- MainMenuState

              |-- GameplayState


                            |-- GameplayInputState

                            |-- HUDGameState

If i in Game class instance ALL states, but only active one (the first: MainMenuState)

This is the good way? i ask it because im instancing in Game and i load all resource in each State class.

Then… ALL my game resource data is loaded, by example, when im in the MenuState, already have in memory ALL MODELS AND TEXTURES of GamePlay, when in really i dont need this, only later when active the child. because all gamestates is instanced in Game class execution.

Load your resources when you load the state and unload it when you're done.  For example, the main menu state would probably always stay around but the gamplay state would only load when you go to load a level and would unload when you quit.

But when?

in what method?

I have this in my BasicGameState constructor

Using StandardGame load them whenever you want.

Im using BasicGameState

public class Compas {

public static void main(String[] args) {

StandardGame game = new StandardGame("Game");





game.getDisplay().setTitle("Compas - D'Arte Games");

// Must ADD all gamestates at MAIN CLASS constructor? this load ALL textures in memory, this not good because by example, im in MainMenuState and dont need fill my memory with textures that now i dont need.

GameStateManager.getInstance().attachChild(new GameplayState());

GameStateManager.getInstance().attachChild(new MainMenuState());