2
\$\begingroup\$

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.

\$\endgroup\$
4
\$\begingroup\$

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 manual.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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