Book Image

JMonkeyEngine 3.0 Cookbook

By : Rickard Eden
Book Image

JMonkeyEngine 3.0 Cookbook

By: Rickard Eden

Overview of this book

Table of Contents (17 chapters)
jMonkeyEngine 3.0 Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Initializing Nifty and managing an options menu


To start things off, let's begin with a simple recipe that will provide us with the basics of setting up the application to use Nifty GUI and tell us how to manage the options menu. An options menu is usually found in games; it acts as a link between different screens. For this reason, it's suitable to create it using the control pattern so it can be easily handled across screens.

We'll initialize Nifty GUI inside AppState to offset it from the main application code and then access the application from Nifty and control Nifty through code.

Getting ready

Let's look at how to initialize Nifty in an application. We start off by defining a new AppState to handle our Nifty functions. We can call it NiftyAppState and have it extend AbstractAppState.

In the initialize method, we need to create the Nifty display with the following line of code, giving Nifty access to various functionalities within the application and telling it to render o in the GUI view...