mirror of
https://github.com/Nimac0/SDL_Minigame
synced 2026-01-12 07:53:43 +00:00
added some tweaks to playSound
This commit is contained in:
parent
24e69b73a2
commit
f78cd2c3f1
@ -152,8 +152,8 @@ void GameInternal::init(const char* title, int xpos, int ypos, int width, int he
|
||||
assets->addTexture("egg", "assets/egg.png");
|
||||
*/
|
||||
// loading sounds
|
||||
assets->addSoundEffect("throw_egg", "assets/sound/throw_egg.wav");
|
||||
assets->addSoundEffect("steps", "assets/sound/steps.wav");
|
||||
// assets->addSoundEffect("throw_egg", "assets/sound/throw_egg.wav");
|
||||
// assets->addSoundEffect("steps", "assets/sound/steps.wav");
|
||||
|
||||
// loading music
|
||||
// assets->addMusic("background_music", "assets/sound/background_music.mp3");
|
||||
|
||||
@ -51,8 +51,16 @@ void SoundManager::playSound(GameInternal* game, std::string sound, bool canOver
|
||||
{
|
||||
if(!canOverlap)
|
||||
{
|
||||
if (Mix_Playing(channel) != 0)
|
||||
Mix_HaltChannel(channel);
|
||||
// dev needs to specify a channel for this check to work, if they set it to -1 and let sdl pick the first available
|
||||
// channel mix_getchunk() won't work
|
||||
if (Mix_Playing(channel) != 0 &&
|
||||
Mix_GetChunk(channel) == game->assets->getSound(sound) &&
|
||||
channel != -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Mix_HaltChannel(channel);
|
||||
}
|
||||
|
||||
if(Mix_VolumeChunk(game->assets->getSound(sound), volume) == -1)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user