Tuesday, October 4, 2016

java - Using Nifty GUI with Slick2D


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.



Answer



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.


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...