Pause music

This commit is contained in:
2023-04-05 11:36:45 -06:00
parent 0b6204b812
commit 6e26051545
3 changed files with 23 additions and 11 deletions

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)

View File

@@ -37,6 +37,7 @@ interface Director<Set:Cloneable<Set>, Actor, Sound, Song, Prop, VoiceTrack, Cam
// - current music
// - input checking
// - tweens
// - credit roll
function pause():Void;
function resume():Void;

View File

@@ -223,7 +223,10 @@
(director.chooseString
"Skip to scene?"
(sort (collect (runners.keys)))
->label ((dictGet runners label))))))
->label {
(resume)
((dictGet runners label))
}))))
(shortcutHandler.start))