Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

As seen here NiftyGUI has it's own GameState classes, I want to know if for adding UI to one state of my game I need to make that state NiftyOverlayGameState or still a BasicGameState but to add a NiftyOverlayGameState as well.

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

From the documentation you linked, here are the different implementions you will have to use based on the functionality you desire:

  • NiftyGame, NiftyBasicGame - Implementing the Game or the BasicGame, this classes are supposed to display only the Nifty-GUI over the entire game.

  • NiftyGameState, NiftyBasicGameState - Implementing the GameState or the BasicGameState, this classes are supposed to display only the Nifty-GUI over the entire state of the game. This can be useful in for GUI-only states such as a login state.

  • NiftyOverlayGame, NiftyOverlayBasicGame - Implementing the Game or the BasicGame, this classes are supposed to display the Nifty-GUI on top of something else. For example on top of the actual game graphics.

  • NiftyOverlayGameState, NiftyOverlayBasicGameState - Implementing the GameState or the BasicGameState, this classes are supposed to display the Nifty-GUI on top of something else, such as the game graphics.

This means if you want to add the NiftyGUI to just one state of your game, you should probably use the NiftyGameState or NiftyBasicGameState.

Then depending on your requirements you'll extend the Slick2D game state with this:

protected void initGameAndGUI(GameContainer container, StateBasedGame game) throws SlickException;

Then inside that you'll call this:

protected final void initNifty(GameContainer container, StateBasedGame game, ...);

For more details, read up on the Preparation and Slick2D-Game Implementations.

share|improve this answer
    
Ok. So i understand how to do that and i did it but, and here comes a big question. Why if i put inside initGameAndGUI() method a call for initNifty(container, game) i get the exception: "The NiftyGUI was already initialized. Its illegal to do so twice." and if i don't i get the exception: "NiftyGUI was not initialized." It's a little disturbing. –  Romeo Apr 6 '12 at 15:56
    
Interesting. You should post the relevant code you're using and the description as a new question to the site. It's often tricky to answer questions in the comments. –  Byte56 Apr 6 '12 at 16:00
    
Okay. Thank you. :D –  Romeo Apr 6 '12 at 16:02
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.