Ok, I got it.
there was a mistake in may source code.
It was like this:
private static void createGameStates()
{
gameStateManager = GameStateManager.create();
root = new RootGameState();
root.setActive(true);
menu = new MenuGameState();
menu.setActive(true);
ingame = new IngameGameState();
ingame.setActive(false);
root.getRootNode().attachChild(menu.getRootNode());
root.getRootNode().attachChild(ingame.getRootNode());
gameStateManager.attachChild(root);
}
The problem with it is, that the GameState.setActive Method only works when a GameState is already added to the GameStateManager (thanks to core-dump). Furthermore if you do it like me:
root.getRootNode().attachChild(menu.getRootNode());
You should not use GameStates. Because they are expected to get handeled by the gamestatemanager not by you!
So, what about the following:
private static void createGameStates()
{
gameStateManager = GameStateManager.create();
root = new RootGameState();
menu = new MenuGameState();
ingame = new IngameGameState();
gameStateManager.attachChild(root);
root.setActive(true);
gameStateManager.attachChild(menu);
menu.setActive(true);
gameStateManager.attachChild(ingame);
ingame.setActive(false);
}
Well, that's it.
So we have created a root-GameState that includes al the others and can get deactivated at the end of the program to deactivate all GameStates automatically - of course this GameState should be active at the runntime of our programm - and a menu GameState that should be active at the beginning of the game. At last there's the ingame GameState that is going to be activated after the start MenuButton being clicked.
There are only two questions remaining:
How can I create a hierachy within the GameStates?
E.g. GameState A is a generalization of GameStates B and C.
And Second, why is the skybox, that I create in the Constructor of IngameGameState visible when IngameGameState is not active? Isn't the skybox simply one part of the rootNode of my IngameGameState? So it should be deactivated with the GameState, because deactivating a gamestate should nothing else then deactivating it's rootNode?
If there are further mistakes or other ways making it better correct me.