allow LOOPSOUND to have volume decay

This commit is contained in:
2024-10-14 12:15:05 -05:00
parent f2f1ce9428
commit 273f1acfa2

View File

@@ -1364,7 +1364,9 @@
(director.stopSound (dictGet sounds name)))) (director.stopSound (dictGet sounds name))))
(cc)) (cc))
(hollywooMethod loopSound [:Bool skipping :String name :Continuation cc &opt :Float volumeMod] (hollywooMethod loopSound [:Bool skipping :String name :Continuation cc &opt :Float volumeMod :Float decay]
(unless decay (set decay 0))
(localVar &mut vm (+ volumeMod decay))
// Even when skipping, create a lambda that plays an iteration of the sound, // Even when skipping, create a lambda that plays an iteration of the sound,
// so if skipping ends and the sound is still supposed to be looping, // so if skipping ends and the sound is still supposed to be looping,
// we can start it! // we can start it!
@@ -1372,11 +1374,15 @@
(withFunctions (withFunctions
[ [
(:Void playAgain [] (:Void playAgain []
(-= vm decay)
(when (and (> decay 0) (< vm 0))
(loopingSoundPlays.remove name)
(return))
(playSound false name (playSound false name
(makeCC null (makeCC null
(when (loopingSoundPlays.exists name) (when (loopingSoundPlays.exists name)
(playAgain))) (playAgain)))
volumeMod vm
true)) true))
] ]
(handleCaption skipping name) (handleCaption skipping name)