bio photo

Slick 2D</a> is a great library for game development. With the upcoming release of Nifty GUI 0.0.4 there will be an even easier way to integrate your Nifty GUI into your Slick application.

The current Nifty GUI Version 0.0.3 can already be used with Slick but it might become a little tricky to save/restore OpenGL state when switching between Slick and Nifty rendering. The basic approach would be to call niftys render() method after you've rendered all of your Slick graphics. This "manual" rendering is the usual way for Nifty integration and is shown in the Hello World example</a> on the Nifty Project Website</a>.

With the Release of Nifty Version 0.0.4 there will be a Slick GameState implementation available for easy of use. If you're new to Slick GameStates there's an article in the Slick wiki</a> about the basic principles. With Nifty 0.0.4 you get a NiftyGameState class that extends the Slick BasicGameState. So you can simply use an instance of this new class (or a subclass) and voila you have the ability to add a Nifty GUI to your Slick app in no time :)

Example:

public void initStatesList(final GameContainer container) throws SlickException {
  NiftyGameState state = new NiftyGameState(MENU_ID);
  state.fromXml("mainmenu.xml", new ScreenController() {
  public void bind(Nifty nifty, Screen screen) {
  }
  public void onEndScreen() {
  }
  public void onStartScreen() {
  }
  });
addState(state);
}</pre>
Nifty! :)