]> git.mxchange.org Git - simgear.git/commitdiff
add <delay-sec> parameter that defines how many seconds after triggering
authormfranz <mfranz>
Wed, 21 May 2008 14:47:06 +0000 (14:47 +0000)
committermfranz <mfranz>
Wed, 21 May 2008 14:47:06 +0000 (14:47 +0000)
the sound should be played (default: 0)

simgear/sound/xmlsound.cxx
simgear/sound/xmlsound.hxx

index efd8d2ad8666cdd59113fb08382d217071e3c1c7..5d6490b99a74afee4c47470ff407ed3ed66a6c28 100644 (file)
@@ -70,6 +70,7 @@ SGXmlSound::SGXmlSound()
     _prev_value(0),
     _dt_play(0.0),
     _dt_stop(0.0),
+    _delay(0.0),
     _stopping(0.0)
 {
 }
@@ -120,6 +121,8 @@ SGXmlSound::init(SGPropertyNode *root, SGPropertyNode *node, SGSoundMgr *sndmgr,
       SG_LOG(SG_GENERAL, SG_WARN,
              "  Neither a condition nor a property specified");
 
+   _delay = node->getDoubleValue("delay-sec", 0.0);
+
    //
    // set volume properties
    //
@@ -348,6 +351,9 @@ SGXmlSound::update (double dt)
       _stopping = 0.0;
    }
 
+   if (_dt_play < _delay)
+      return;
+
    //
    // Update the volume
    //
index 99bd9b268d6ccefb54bd3494725d9bb6c108cfd2..de1be7b627c577937ece12c9f5d7d20fd0050a8a 100644 (file)
@@ -76,6 +76,7 @@ public:
    *    <path/> The relative path to the audio file.
    *    <property/> Take action if this property becomes true.
    *    <condition/> Take action if this condition becomes true.
+   *    <delay-sec/> Time after which the sound should be played.
    *    <volume> or <pitch> Define volume or pitch settings.
    *     <property/> Take the value of this property as a refference for the
    *                 result.
@@ -144,6 +145,7 @@ private:
   double _prev_value;
   double _dt_play;
   double _dt_stop;
+  double _delay;        // time after which the sound should be started (default: 0)
   double _stopping;    // time after the sound should have stopped.
                        // This is usefull for lost packets in in-trasit mode.