ソースを参照

SimpleApplication has now built in methods to display or not fps tex and stat view.

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7008 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
rem..om 14 年 前
コミット
d9f39f6b0b
1 ファイル変更19 行追加5 行削除
  1. 19 5
      engine/src/core/com/jme3/app/SimpleApplication.java

+ 19 - 5
engine/src/core/com/jme3/app/SimpleApplication.java

@@ -73,6 +73,7 @@ public abstract class SimpleApplication extends Application {
     protected StatsView statsView;
     protected FlyByCamera flyCam;
     protected boolean showSettings = true;
+    private  boolean showFps = true;
     private AppActionListener actionListener = new AppActionListener();
 
     private class AppActionListener implements ActionListener {
@@ -227,11 +228,13 @@ public abstract class SimpleApplication extends Application {
 
         float tpf = timer.getTimePerFrame() * speed;
 
-        secondCounter += timer.getTimePerFrame();
-        int fps = (int) timer.getFrameRate();
-        if (secondCounter >= 1.0f) {
-            fpsText.setText("Frames per second: " + fps);
-            secondCounter = 0.0f;
+        if (showFps) {
+            secondCounter += timer.getTimePerFrame();
+            int fps = (int) timer.getFrameRate();
+            if (secondCounter >= 1.0f) {
+                fpsText.setText("Frames per second: " + fps);
+                secondCounter = 0.0f;
+            }          
         }
 
         // update states
@@ -251,6 +254,17 @@ public abstract class SimpleApplication extends Application {
         stateManager.postRender();
     }
 
+    public void setDisplayFps(boolean show) {
+        showFps = show;
+        fpsText.setCullHint(show ? CullHint.Never : CullHint.Always);
+
+    }
+
+    public void setDisplayStatView(boolean show) {
+        statsView.setEnabled(show);
+        statsView.setCullHint(show ? CullHint.Never : CullHint.Always);
+    }
+
     public abstract void simpleInitApp();
 
     public void simpleUpdate(float tpf) {