Pause music

This commit is contained in:
2023-04-05 11:36:45 -06:00
parent ec7f5f7a49
commit 35e16f7ce9

View File

@@ -33,7 +33,8 @@
(FlxG.inputs.remove actionManager) (FlxG.inputs.remove actionManager)
(doFor sound currentSounds (doFor sound currentSounds
(sound.pause)) (sound.pause))
// TODO music (when music
(music.pause))
// TODO tweens // TODO tweens
) )
@@ -41,7 +42,8 @@
(FlxG.inputs.add actionManager) (FlxG.inputs.add actionManager)
(doFor sound currentSounds (doFor sound currentSounds
(sound.resume)) (sound.resume))
// TODO music (when music
(music.resume))
// TODO tweens // TODO tweens
) )
@@ -367,15 +369,21 @@
(prop MUSIC_FADE_SEC 1) (prop MUSIC_FADE_SEC 1)
(prop MUSIC_FADE_STEPS 10) (prop MUSIC_FADE_STEPS 10)
(method :Void playSong [:String song :Float volumeMod :Bool loop :Bool waitForEnd :Continuation cc] (method :Void playSong [:String song :Float volumeMod :Bool loop :Bool waitForEnd :Continuation cc]
(set music (FlxG.sound.play song 0 loop null true (if waitForEnd cc ->{}))) (let [onFinish ->{
(.start (new FlxTimer) (set music null)
(/ MUSIC_FADE_SEC MUSIC_FADE_STEPS) (when waitForEnd (cc))
->:Void _ (+= music.volume (/ volumeMod MUSIC_FADE_STEPS)) }]
MUSIC_FADE_STEPS) (set music (FlxG.sound.play song 0 loop null true onFinish))
(set music.persist true) (.start (new FlxTimer)
(unless waitForEnd (cc))) (/ MUSIC_FADE_SEC MUSIC_FADE_STEPS)
->:Void _ (+= music.volume (/ volumeMod MUSIC_FADE_STEPS))
MUSIC_FADE_STEPS)
(set music.persist true)
(unless waitForEnd (cc))))
(method :Void stopSong [] (when music (music.stop))) (method :Void stopSong []
(when music (music.stop))
(set music null))
(var PROP_MIN_WIDTH 200) (var PROP_MIN_WIDTH 200)
(var PROP_MAX_WIDTH 500) (var PROP_MAX_WIDTH 500)