Make some flyable sfx lower volume in splitscreen multiplayer

This commit is contained in:
Benau 2021-08-10 08:46:45 +08:00
parent ad531ba556
commit 5ec99947e9
4 changed files with 13 additions and 0 deletions

View File

@ -38,6 +38,7 @@ Bowling::Bowling(AbstractKart *kart)
{
m_has_hit_kart = false;
m_roll_sfx = SFXManager::get()->createSoundSource("bowling_roll");
fixSFXSplitscreen(m_roll_sfx);
m_roll_sfx->play();
m_roll_sfx->setLoop(true);
} // Bowling

View File

@ -26,6 +26,7 @@
#include <IMeshManipulator.h>
#include <IMeshSceneNode.h>
#include "audio/sfx_base.hpp"
#include "achievements/achievements_status.hpp"
#include "config/player_manager.hpp"
#include "graphics/explosion.hpp"
@ -809,4 +810,12 @@ void Flyable::onDeleteFlyable()
moveToInfinity();
} // onDeleteFlyable
// ----------------------------------------------------------------------------
/* Make specifc sfx lower volume if needed in splitscreen multiplayer. */
void Flyable::fixSFXSplitscreen(SFXBase* sfx)
{
if (sfx && RaceManager::get()->getNumLocalPlayers() > 1)
sfx->setVolume(1.0f / (float)RaceManager::get()->getNumLocalPlayers());
} // fixSFXSplitscreen
/* EOF */

View File

@ -39,6 +39,7 @@ class AbstractKart;
class AbstractKartAnimation;
class HitEffect;
class PhysicalObject;
class SFXBase;
class XMLNode;
/**
@ -184,6 +185,7 @@ protected:
void moveToInfinity(bool set_moveable_trans = true);
void removePhysics();
void fixSFXSplitscreen(SFXBase* sfx);
public:
Flyable (AbstractKart* kart,

View File

@ -71,6 +71,7 @@ RubberBall::RubberBall(AbstractKart *kart)
m_target = NULL;
m_ping_sfx = SFXManager::get()->createSoundSource("ball_bounce");
fixSFXSplitscreen(m_ping_sfx);
} // RubberBall
// ----------------------------------------------------------------------------