Browse Source

*** empty log message ***

Mark Mine 24 years ago
parent
commit
641a42616a

+ 5 - 3
direct/src/interval/ActorInterval.py

@@ -37,9 +37,8 @@ class ActorInterval(Interval):
 	Interval.__init__(self, name, duration)
 	Interval.__init__(self, name, duration)
         # Update stopEvent
         # Update stopEvent
         if self.loop:
         if self.loop:
-            stopEvent = id + '_stopEvent'
-            self.stopEventList = [stopEvent]
-            self.accept(stopEvent, self.actor.stop)
+            self.stopEvent = id + '_stopEvent'
+            self.stopEventList = [self.stopEvent]
 
 
     def updateFunc(self, t, event = IVAL_NONE):
     def updateFunc(self, t, event = IVAL_NONE):
 	""" updateFunc(t, event)
 	""" updateFunc(t, event)
@@ -49,6 +48,8 @@ class ActorInterval(Interval):
         # Pose or stop anim
         # Pose or stop anim
         if (t >= self.getDuration()):
         if (t >= self.getDuration()):
             self.actor.stop()
             self.actor.stop()
+            if self.loop:
+                self.ignore(self.stopEvent)
         elif self.loop == 1:
         elif self.loop == 1:
             if event == IVAL_INIT:
             if event == IVAL_INIT:
                 # Determine the current frame
                 # Determine the current frame
@@ -58,6 +59,7 @@ class ActorInterval(Interval):
                 self.actor.pose(self.animName, frame)
                 self.actor.pose(self.animName, frame)
                 # And start loop, restart flag says continue from current frame
                 # And start loop, restart flag says continue from current frame
                 self.actor.loop(self.animName, restart=0)
                 self.actor.loop(self.animName, restart=0)
+                self.accept(self.stopEvent, self.actor.stop)
         else:
         else:
             # Determine the current frame
             # Determine the current frame
             frame = (int(self.actor.getFrameRate(self.animName) * t) %
             frame = (int(self.actor.getFrameRate(self.animName) * t) %

+ 11 - 6
direct/src/interval/IntervalTest.py

@@ -17,6 +17,7 @@ dock = loader.loadModel('models/directmodels/smiley')
 dock.reparentTo(render)
 dock.reparentTo(render)
 
 
 sound = loader.loadSound('phase_6/audio/sfx/SZ_DD_waterlap.mp3')
 sound = loader.loadSound('phase_6/audio/sfx/SZ_DD_waterlap.mp3')
+foghorn = loader.loadSound('phase_6/audio/sfx/SZ_DD_foghorn.mp3')
 
 
 mp = Mopath.Mopath()
 mp = Mopath.Mopath()
 mp.loadFile(Filename('phase_6/paths/dd-e-w'))
 mp.loadFile(Filename('phase_6/paths/dd-e-w'))
@@ -62,16 +63,20 @@ waterDone = EventInterval('water-is-done')
 waterEventTrack = Track([waterDone])
 waterEventTrack = Track([waterDone])
 waterEventTrack.setIntervalStartTime('water-is-done', eventTime)
 waterEventTrack.setIntervalStartTime('water-is-done', eventTime)
 
 
-mtrack = MultiTrack([boatTrack, dockTrack, soundTrack, waterEventTrack,
-                     donaldSteerTrack])
-# Print out MultiTrack parameters
-print(mtrack)
-
 def handleWaterDone():
 def handleWaterDone():
     print 'water is done'
     print 'water is done'
 
 
-messenger.accept('water-is-done', 1, handleWaterDone)
+# Interval can handle its own event
+messenger.accept('water-is-done', waterDone, handleWaterDone)
 
 
+foghornStartTime = BOAT_START + 4.0
+foghornSound = SoundInterval(foghorn, name='foghorn')
+soundTrack2 = Track([(foghornStartTime, foghornSound)], 'soundtrack2')
+
+mtrack = MultiTrack([boatTrack, dockTrack, soundTrack, soundTrack2, waterEventTrack,
+                     donaldSteerTrack])
+# Print out MultiTrack parameters
+print(mtrack)
 
 
 ### Using lambdas and functions ###
 ### Using lambdas and functions ###
 # Using a lambda
 # Using a lambda

+ 5 - 3
direct/src/interval/SoundInterval.py

@@ -43,9 +43,8 @@ class SoundInterval(Interval):
 	Interval.__init__(self, name, duration)
 	Interval.__init__(self, name, duration)
         # Update stopEvent
         # Update stopEvent
         if self.wantSound:
         if self.wantSound:
-            stopEvent = id + '_stopEvent'
-            self.stopEventList = [stopEvent]
-            self.accept(stopEvent, lambda s = self: AudioManager.stop(s.sound))
+            self.stopEvent = id + '_stopEvent'
+            self.stopEventList = [self.stopEvent]
         
         
     def updateFunc(self, t, event = IVAL_NONE):
     def updateFunc(self, t, event = IVAL_NONE):
 	""" updateFunc(t, event)
 	""" updateFunc(t, event)
@@ -57,6 +56,7 @@ class SoundInterval(Interval):
         if (t >= self.getDuration()):
         if (t >= self.getDuration()):
             # If end of sound reached or stop event received, stop sound
             # If end of sound reached or stop event received, stop sound
             AudioManager.stop(self.sound)
             AudioManager.stop(self.sound)
+            self.ignore(self.stopEvent)
         elif (event == IVAL_INIT):
         elif (event == IVAL_INIT):
             # IVAL_INIT event, start new sound
             # IVAL_INIT event, start new sound
             # If its within a 10th of a second of the start,
             # If its within a 10th of a second of the start,
@@ -68,3 +68,5 @@ class SoundInterval(Interval):
             # Loop in necessary
             # Loop in necessary
 	    if (self.loop):
 	    if (self.loop):
 		AudioManager.setLoop(self.sound, 1)
 		AudioManager.setLoop(self.sound, 1)
+            # Accept event to kill sound
+            self.accept(self.stopEvent, lambda s = self: AudioManager.stop(s.sound))