浏览代码

Modified fly cam to be a little more resilient
in the face of being called before it sees an
input manager.


git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9162 75d07b2b-3a1a-0410-a2c5-0572b91ccdca

PSp..om 13 年之前
父节点
当前提交
0c835eae80
共有 1 个文件被更改,包括 9 次插入3 次删除
  1. 9 3
      engine/src/core/com/jme3/input/FlyByCamera.java

+ 9 - 3
engine/src/core/com/jme3/input/FlyByCamera.java

@@ -124,7 +124,7 @@ public class FlyByCamera implements AnalogListener, ActionListener {
      */
     public void setEnabled(boolean enable){
         if (enabled && !enable){
-            if (!dragToRotate || (dragToRotate && canRotate)){
+            if (inputManager!= null && (!dragToRotate || (dragToRotate && canRotate))){
                 inputManager.setCursorVisible(true);
             }
         }
@@ -161,7 +161,9 @@ public class FlyByCamera implements AnalogListener, ActionListener {
      */
     public void setDragToRotate(boolean dragToRotate) {
         this.dragToRotate = dragToRotate;
-        inputManager.setCursorVisible(dragToRotate);
+        if (inputManager != null) {
+            inputManager.setCursorVisible(dragToRotate);
+        }
     }
 
     /**
@@ -199,7 +201,7 @@ public class FlyByCamera implements AnalogListener, ActionListener {
         inputManager.addMapping("FLYCAM_Lower", new KeyTrigger(KeyInput.KEY_Z));
 
         inputManager.addListener(this, mappings);
-        inputManager.setCursorVisible(dragToRotate);
+        inputManager.setCursorVisible(dragToRotate || !isEnabled());
 
         Joystick[] joysticks = inputManager.getJoysticks();
         if (joysticks != null && joysticks.length > 0){
@@ -218,6 +220,10 @@ public class FlyByCamera implements AnalogListener, ActionListener {
      */
     public void unregisterInput(){
     
+        if (inputManager == null) {
+            return;
+        }
+    
         for (String s : mappings) {
             inputManager.deleteMapping( s );
         }