fix roll sound popping

This commit is contained in:
RandomityGuy 2023-07-18 23:16:05 +05:30
parent 0b69c27a4f
commit 5cc595bbe7

View file

@ -963,7 +963,7 @@ class Marble extends GameObject {
if (rollVolume > 1) if (rollVolume > 1)
rollVolume = 1; rollVolume = 1;
if (contactPct < 0.05) if (contactPct < 0.05)
rollVolume = 0; rollVolume = rollSound.volume / 5; // We decrease it slowly
var slipVolume = 0.0; var slipVolume = 0.0;
if (slipAmount > 1e-4) { if (slipAmount > 1e-4) {
@ -989,7 +989,7 @@ class Marble extends GameObject {
rollMegaSound.volume = 0; rollMegaSound.volume = 0;
} }
} }
slipSound.volume = slipVolume; slipVolume = 0;
if (rollSound.getEffect(Pitch) == null) { if (rollSound.getEffect(Pitch) == null) {
rollSound.addEffect(new Pitch()); rollSound.addEffect(new Pitch());
@ -1001,13 +1001,8 @@ class Marble extends GameObject {
} }
} }
var pitch = Util.clamp(rollVel.length() / 15, 0, 1) * 0.75 + 0.75; var pitch = Util.clamp(rollVel.length() / _maxRollVelocity, 0, 1) * 0.75 + 0.75;
// #if js
// // Apparently audio crashes the whole thing if pitch is less than 0.2
// if (pitch < 0.2)
// pitch = 0.2;
// #end
var rPitch = rollSound.getEffect(Pitch); var rPitch = rollSound.getEffect(Pitch);
rPitch.value = pitch; rPitch.value = pitch;