Time for action – mapping meets listeners

To activate the mappings, you have to register them to an InputListener object. The jMonkeyEngine offers several InputListener objects in the com.jme3.input.controls.* package. Let's create instances of the two most common InputListener objects and compare what they do.

  1. On class level, below the closing curly braces of the simpleInitApp() method, add the following code snippet:
    private ActionListener actionListener = new ActionListener() { public void onAction(String name, boolean isPressed, float tpf) { System.out.println("You triggered: "+name); } }; private AnalogListener analogListener = new AnalogListener() { public void onAnalog(String name, float intensity, float tpf) { System.out.println("You triggered: ...

Get jMonkeyEngine 3.0 Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.