Browse Source

*** empty log message ***

Mike Goslin 25 years ago
parent
commit
89f7969c9e
2 changed files with 30 additions and 30 deletions
  1. 30 0
      direct/src/interval/Interval.py
  2. 0 30
      direct/src/interval/MultiTrack.py

+ 30 - 0
direct/src/interval/Interval.py

@@ -2,6 +2,9 @@
 
 from DirectObject import *
 
+import ClockObject
+import Task
+
 class Interval(DirectObject):
     """Interval class: Base class for timeline functionality"""
 
@@ -16,6 +19,7 @@ class Interval(DirectObject):
         """
 	self.name = name
 	self.duration = duration
+	self.clock = ClockObject.ClockObject.getGlobalClock()
 
     def getName(self):
 	""" getName()
@@ -38,6 +42,32 @@ class Interval(DirectObject):
 	"""
 	self.setT(self.getDuration(), entry=1)
 
+    def play(self, t0=0.0, duration=0.0):
+        """ play(t0, duration)
+        """
+        self.startT = self.clock.getFrameTime() - t0
+        if (duration == 0.0):
+            self.playDuration = self.duration
+        else:
+            self.playDuration = duration
+        taskMgr.spawnMethodNamed(self.__playTask, self.name + '-play')
+
+    def stop(self):
+        """ stop()
+        """
+        taskMgr.removeTasksNamed(self.name + '-play')
+
+    def __playTask(self, task):
+        """ __playTask(task)
+        """
+        t = self.clock.getFrameTime()
+        te = t - self.startT
+        if (te <= self.playDuration):
+            self.setT(te)
+            return Task.cont
+        else:
+            return Task.done
+
     def printParams(self, indent=0):
 	""" printParams(indent)
 	"""

+ 0 - 30
direct/src/interval/MultiTrack.py

@@ -3,9 +3,6 @@
 from Interval import *
 from Track import *
 
-import ClockObject
-import Task
-
 class MultiTrack(Interval):
 
     multiTrackNum = 1
@@ -22,7 +19,6 @@ class MultiTrack(Interval):
 	    n = name
 	self.tlist = trackList
 	duration = self.__computeDuration()
-	self.clock = ClockObject.ClockObject.getGlobalClock()
 	Interval.__init__(self, n, duration)
 
     def __computeDuration(self):
@@ -46,32 +42,6 @@ class MultiTrack(Interval):
 	for track in self.tlist:
 	    track.setT(t, entry)
 
-    def play(self, t0=0.0, duration=0.0):
-	""" play(t0, duration)
-	"""
-	self.startT = self.clock.getFrameTime() - t0
-	if (duration == 0.0):
-	    self.playDuration = self.duration
-	else:
-	    self.playDuration = duration
-	taskMgr.spawnMethodNamed(self.__playTask, self.name + '-play')
-
-    def stop(self):
-	""" stop()
-	"""
-	taskMgr.removeTasksNamed(self.name + '-play')
-
-    def __playTask(self, task):
-	""" __playTask(task)
-	"""
-	t = self.clock.getFrameTime()
-	te = t - self.startT
-	if (te <= self.playDuration):
-	    self.setT(te)
-	    return Task.cont
-	else:
-	    return Task.done
-
     def printParams(self, indent=0):
 	""" printParams(indent)
 	"""