Hello good people,
I'm new to jME and much of it's conceptual underpinnings (3D, physics, etc.); not new to Java, though.
I'm having difficulty, and it seems to be related to building a GameState tree properly using StandardGame.
From my log messages, I know that:
- I am passing my GameState instances to GameStateManager.attachChild()
- I am calling setActive(true) on my GameState instances
- The update() and render() methods of my GameState instances are not being called by jME
I've got a solid black screen.
I'm guessing there's something fundamental I'm overlooking.
Code sample:
public static void main(final String[] args) {
// Instance Members...
final Log log = LogFactory.getLog(Main.class);
// Create & load the app context...
final ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(CONTEXT_LOCATION_PATTERN);
final GameState activate = (GameState) ctx.getBean(ACTIVATE_GAME_STATE_BEAN);
try {
final GameTaskQueueManager gameTaskQueue = GameTaskQueueManager.getManager();
// Attach game states to the manager...
final List<GameState> gameStates = (List<GameState>) ctx.getBean(GAME_STATES_BEAN);
gameTaskQueue.update(new Callable() {
public Object call() throws Exception {
for (final GameState s : gameStates) {
if (log.isDebugEnabled()) {
log.debug("Registering GameState with GameStateManager: " + s.getName());
}
GameStateManager.getInstance().attachChild(s);
}
return null;
}
}).get();
// Activate the specified state...
gameTaskQueue.update(new Callable() {
public Object call() throws Exception {
if (log.isDebugEnabled()) {
log.debug("Activating GameState: " + activate.getName());
}
GameStateManager.getInstance().activateChildNamed(activate.getName());
return null;
}
}).get();
} catch (Throwable t) {
String msg = "Failed to activate the game state: " + activate.getName();
throw new RuntimeException(msg, t);
}
}
Thanks for any suggestions!