Avoid nuisance sounds in initial update loop.
Stop all "in-transit" sounds effects from triggering in the first update loop when their initial property value is "1".
This commit is contained in:
@@ -68,7 +68,8 @@ SGXmlSound::SGXmlSound()
|
||||
_dt_play(0.0),
|
||||
_dt_stop(0.0),
|
||||
_delay(0.0),
|
||||
_stopping(0.0)
|
||||
_stopping(0.0),
|
||||
_initialized(false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -298,6 +299,13 @@ SGXmlSound::update (double dt)
|
||||
if (_property)
|
||||
curr_value = _property->getDoubleValue();
|
||||
|
||||
if (!_initialized)
|
||||
{
|
||||
// update initial value before detecting changes
|
||||
_prev_value = curr_value;
|
||||
_initialized = true;
|
||||
}
|
||||
|
||||
// If a condition is defined, test whether it is FALSE,
|
||||
// else
|
||||
// if a property is defined then test if it's value is FALSE
|
||||
|
||||
@@ -149,12 +149,12 @@ private:
|
||||
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 useful for lost packets in in-transit mode.
|
||||
double _stopping; // time after the sound should have stopped.
|
||||
// This is useful for lost packets in in-transit mode.
|
||||
bool _initialized;
|
||||
|
||||
std::vector<_snd_prop> _volume;
|
||||
std::vector<_snd_prop> _pitch;
|
||||
|
||||
};
|
||||
|
||||
#endif // _SG_SOUND_HXX
|
||||
|
||||
Reference in New Issue
Block a user