瀏覽代碼

fix setPlayRate() on running MetaInterval

David Rose 15 年之前
父節點
當前提交
be3a0f3520
共有 1 個文件被更改,包括 13 次插入0 次删除
  1. 13 0
      direct/src/interval/MetaInterval.py

+ 13 - 0
direct/src/interval/MetaInterval.py

@@ -460,6 +460,19 @@ class MetaInterval(CMetaInterval):
         else:
             self.notify.error("Cannot build list from MetaInterval directly.")
 
+    def setPlayRate(self, playRate):
+        """ Changes the play rate of the interval.  If the interval is
+        already started, this changes its speed on-the-fly.  Note that
+        since playRate is a parameter to start() and loop(), the next
+        call to start() or loop() will reset this parameter. """
+        
+        if self.isPlaying():
+            self.pause()
+            CMetaInterval.setPlayRate(self, playRate)
+            self.resume()
+        else:
+            CMetaInterval.setPlayRate(self, playRate)
+
     def __doPythonCallbacks(self):
         # This function invokes any Python-level Intervals that need
         # to be invoked at this point in time.  It must be called