By following the StandardGame example, I've created a little test app but I can't seem to figure out how to get get GameStates that are attached to GameStateManager to run their update methods.
public static void main(String[] args) throws Exception {
// Instantiate StandardGame
StandardGame game = new StandardGame("A Simple Test");
// Create a DebugGameState - has all the built-in features that SimpleGame provides
// NOTE: for a distributable game implementation you'll want to use something like
// BasicGameState instead and provide control features yourself.
DebugGameState state;
// the terrain we will drive over.
GameTerrain terrain;
// Show settings screen
if (GameSettingsPanel.prompt(game.getSettings())) {
// Start StandardGame, it will block until it has initialized successfully, then return
game.start();
state = new DebugGameState();
terrain = new GameTerrain("Terrain",game);
state.getRootNode().attachChild(terrain.getTerrainBlock());
// Put our box in it
Box box = new Box("my box", new Vector3f(0, 0, 0), 2, 2, 2);
box.setModelBound(new BoundingSphere());
box.updateModelBound();
// We had to add the following line because the render thread is already running
// Anytime we add content we need to updateRenderState or we get funky effects
box.updateRenderState();
state.getRootNode().attachChild(box);
// Add it to the manager
GameStateManager.getInstance().attachChild(state);
// Activate the game state
state.setActive(true);
}
}
In the above snippet, GameTerrain extends GameState and does nothing other than make a terrain block, put a texture on it, etc. The textured terrain shows up as expected but the update method of GameTerrain is not being called... It seems like the snippet above is setting up the StandardGame but isn't calling update on my GameTerrain's class... any idea what I'm doing wrong? I've read the wiki entries on GameStates but they don't really discuss how to use them to create a main game loop...
//load a detail texture and set the combine modes for the two terrain textures.
Texture t2 = TextureManager.loadTexture(
TestTerrain.class.getClassLoader().getResource(
"jmetest/data/texture/Detail.jpg"),
Texture.MM_LINEAR_LINEAR,
Texture.FM_LINEAR);
I don't see you overriding the GameState's update to call your terrain's update call… you need to do that explicitly, the DebugGameState does not know what method to call depending on each object that is attached… It only calls updateGeometricState on the root node at each iteration.
Which update method are you talking about in your terrain?