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

Customizing the input and settings page


Just about every modern game lets the player customize the input according to their own preferences. This recipe will rely on jMonkeyEngine to do the work for us, and we will use Nifty GUI as a visual aid. We'll use RawInputListener to work out which keys have been pressed and divide them between key codes and characters using the Keyboard class.

Getting ready

The recipe will depend on there being some bindings in InputManager. If you already have a game, this would not be a problem. If not, it will describe how to add a couple of bindings for the example to work.

How to do it...

Following the pattern from previous recipes, we'll start defining the controls, then move on to the screen, and finally work on the controller. Adding the controls and screen will consist of the following eight steps:

  1. Inside a <nifty-control> tag, we define a new <controlDefinition name="keyBindingControl">.

  2. Here, we'll add a horizontal spanning panel with some margin...