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)
(doFor sound currentSounds
(sound.pause))
// TODO music
(when music
(music.pause))
// TODO tweens
)
@@ -41,7 +42,8 @@
(FlxG.inputs.add actionManager)
(doFor sound currentSounds
(sound.resume))
// TODO music
(when music
(music.resume))
// TODO tweens
)
@@ -367,15 +369,21 @@
(prop MUSIC_FADE_SEC 1)
(prop MUSIC_FADE_STEPS 10)
(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 ->{})))
(.start (new FlxTimer)
(/ MUSIC_FADE_SEC MUSIC_FADE_STEPS)
->:Void _ (+= music.volume (/ volumeMod MUSIC_FADE_STEPS))
MUSIC_FADE_STEPS)
(set music.persist true)
(unless waitForEnd (cc)))
(let [onFinish ->{
(set music null)
(when waitForEnd (cc))
}]
(set music (FlxG.sound.play song 0 loop null true onFinish))
(.start (new FlxTimer)
(/ 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_MAX_WIDTH 500)