Kaynağa Gözat

Added a setTimer() method for switching the default
Timer implementation.


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

PSp..om 14 yıl önce
ebeveyn
işleme
2a65ca4cb7
1 değiştirilmiş dosya ile 22 ekleme ve 1 silme
  1. 22 1
      engine/src/core/com/jme3/app/Application.java

+ 22 - 1
engine/src/core/com/jme3/app/Application.java

@@ -197,11 +197,32 @@ public class Application implements SystemListener {
         }
     }
 
+    /**
+     * Sets the Timer implementation that will be used for calculating
+     * frame times.  By default, Application will use the Timer as returned
+     * by the current JmeContext implementation.
+     */
+    public void setTimer(Timer timer){
+        this.timer = timer;
+        
+        if (timer != null) {
+            timer.reset();
+        }
+        
+        if (renderManager != null) {
+            renderManager.setTimer(timer);
+        }
+    } 
+
     private void initDisplay(){
         // aquire important objects
         // from the context
         settings = context.getSettings();
-        timer = context.getTimer();
+ 
+        // Only reset the timer if a user has not already provided one       
+        if (timer == null) {
+            timer = context.getTimer();
+        }
        
         renderer = context.getRenderer();
     }