OSDN Git Service

Added a setTimer() method for switching the default
authorPSpeed42@gmail.com <PSpeed42@gmail.com@75d07b2b-3a1a-0410-a2c5-0572b91ccdca>
Mon, 24 Oct 2011 19:31:50 +0000 (19:31 +0000)
committerPSpeed42@gmail.com <PSpeed42@gmail.com@75d07b2b-3a1a-0410-a2c5-0572b91ccdca>
Mon, 24 Oct 2011 19:31:50 +0000 (19:31 +0000)
Timer implementation.

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

engine/src/core/com/jme3/app/Application.java

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