Turned the magic input mapping strings into constants to

make it easier to unbind them if desired.


git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7242 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
PSp..om 14 years ago
parent d729da9e78
commit 255fe9f9c9
  1. 20
      engine/src/core/com/jme3/app/SimpleApplication.java

@ -65,6 +65,10 @@ import com.jme3.util.BufferUtils;
*/
public abstract class SimpleApplication extends Application {
public static final String INPUT_MAPPING_EXIT = "SIMPLEAPP_Exit";
public static final String INPUT_MAPPING_CAMERA_POS = "SIMPLEAPP_CameraPos";
public static final String INPUT_MAPPING_MEMORY = "SIMPLEAPP_Memory";
protected Node rootNode = new Node("Root Node");
protected Node guiNode = new Node("Gui Node");
protected float secondCounter = 0.0f;
@ -83,9 +87,9 @@ public abstract class SimpleApplication extends Application {
return;
}
if (name.equals("SIMPLEAPP_Exit")) {
if (name.equals(INPUT_MAPPING_EXIT)) {
stop();
} else if (name.equals("SIMPLEAPP_CameraPos")) {
} else if (name.equals(INPUT_MAPPING_CAMERA_POS)) {
if (cam != null) {
Vector3f loc = cam.getLocation();
Quaternion rot = cam.getRotation();
@ -94,7 +98,7 @@ public abstract class SimpleApplication extends Application {
System.out.println("Camera Rotation: " + rot);
System.out.println("Camera Direction: " + cam.getDirection());
}
} else if (name.equals("SIMPLEAPP_Memory")) {
} else if (name.equals(INPUT_MAPPING_MEMORY)) {
BufferUtils.printCurrentDirectMemory(null);
}
}
@ -206,13 +210,13 @@ public abstract class SimpleApplication extends Application {
flyCam.registerWithInput(inputManager);
if (context.getType() == Type.Display) {
inputManager.addMapping("SIMPLEAPP_Exit", new KeyTrigger(KeyInput.KEY_ESCAPE));
inputManager.addMapping(INPUT_MAPPING_EXIT, new KeyTrigger(KeyInput.KEY_ESCAPE));
}
inputManager.addMapping("SIMPLEAPP_CameraPos", new KeyTrigger(KeyInput.KEY_C));
inputManager.addMapping("SIMPLEAPP_Memory", new KeyTrigger(KeyInput.KEY_M));
inputManager.addListener(actionListener, "SIMPLEAPP_Exit",
"SIMPLEAPP_CameraPos", "SIMPLEAPP_Memory");
inputManager.addMapping(INPUT_MAPPING_CAMERA_POS, new KeyTrigger(KeyInput.KEY_C));
inputManager.addMapping(INPUT_MAPPING_MEMORY, new KeyTrigger(KeyInput.KEY_M));
inputManager.addListener(actionListener, INPUT_MAPPING_EXIT,
INPUT_MAPPING_CAMERA_POS, INPUT_MAPPING_MEMORY);
}
// call user code

Loading…
Cancel
Save