diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2021-03-13 11:43:29 -0500 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2021-03-13 15:34:50 -0500 |
commit | c6b5e936ff9869d8a3de9ea41db784a4cb46a818 (patch) | |
tree | 37168fc870be1cae9ae12771b0e6156437bb3c98 | |
parent | 10c92d7f54759d9356ac948f6d019a82e40e3f4d (diff) | |
download | tanetane-c6b5e936ff9869d8a3de9ea41db784a4cb46a818.tar.gz tanetane-c6b5e936ff9869d8a3de9ea41db784a4cb46a818.tar.bz2 tanetane-c6b5e936ff9869d8a3de9ea41db784a4cb46a818.zip |
Sound effects are paused on the pause menu
#7
-rw-r--r-- | src/menu_system.cpp | 2 | ||||
-rw-r--r-- | src/mixer.cpp | 8 | ||||
-rw-r--r-- | src/mixer.h | 4 |
3 files changed, 14 insertions, 0 deletions
diff --git a/src/menu_system.cpp b/src/menu_system.cpp index 6b03fca..7631e4d 100644 --- a/src/menu_system.cpp +++ b/src/menu_system.cpp | |||
@@ -10,6 +10,7 @@ void MenuSystem::tick(double dt) { | |||
10 | openState_ = OpenState::Closed; | 10 | openState_ = OpenState::Closed; |
11 | 11 | ||
12 | game_.unpauseGameplay(); | 12 | game_.unpauseGameplay(); |
13 | game_.getMixer().unpauseSounds(); | ||
13 | } else if (pauseAnimation_.getProgress() == 1.0) { | 14 | } else if (pauseAnimation_.getProgress() == 1.0) { |
14 | openState_ = OpenState::Open; | 15 | openState_ = OpenState::Open; |
15 | } | 16 | } |
@@ -64,6 +65,7 @@ void MenuSystem::openPauseMenu() { | |||
64 | 65 | ||
65 | cursor_ = 0; | 66 | cursor_ = 0; |
66 | 67 | ||
68 | game_.getMixer().pauseSounds(); | ||
67 | game_.getMixer().playSound("../res/sfx/menu_open.wav"); | 69 | game_.getMixer().playSound("../res/sfx/menu_open.wav"); |
68 | } | 70 | } |
69 | 71 | ||
diff --git a/src/mixer.cpp b/src/mixer.cpp index 37c2177..4e8f307 100644 --- a/src/mixer.cpp +++ b/src/mixer.cpp | |||
@@ -23,6 +23,14 @@ void Mixer::stopChannel(int channel) { | |||
23 | Mix_HaltChannel(channel); | 23 | Mix_HaltChannel(channel); |
24 | } | 24 | } |
25 | 25 | ||
26 | void Mixer::pauseSounds() { | ||
27 | Mix_Pause(-1); | ||
28 | } | ||
29 | |||
30 | void Mixer::unpauseSounds() { | ||
31 | Mix_Resume(-1); | ||
32 | } | ||
33 | |||
26 | void Mixer::playMusic(std::string_view name, int ms) { | 34 | void Mixer::playMusic(std::string_view name, int ms) { |
27 | Mix_Music* song = getMusicByName(name); | 35 | Mix_Music* song = getMusicByName(name); |
28 | int ret; | 36 | int ret; |
diff --git a/src/mixer.h b/src/mixer.h index b049118..854c67d 100644 --- a/src/mixer.h +++ b/src/mixer.h | |||
@@ -72,6 +72,10 @@ public: | |||
72 | 72 | ||
73 | void stopChannel(int channel); | 73 | void stopChannel(int channel); |
74 | 74 | ||
75 | void pauseSounds(); | ||
76 | |||
77 | void unpauseSounds(); | ||
78 | |||
75 | // name is the name of the file, not containing the extension | 79 | // name is the name of the file, not containing the extension |
76 | // ms is the time in milliseconds to fade in | 80 | // ms is the time in milliseconds to fade in |
77 | void playMusic(std::string_view name, int ms = 0); | 81 | void playMusic(std::string_view name, int ms = 0); |