mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-06-04 10:44:42 +00:00
sound callback ok
This commit is contained in:
@@ -54,17 +54,16 @@ namespace BBM
|
|||||||
this->_soundList[this->_soundIndex].get()->pause();
|
this->_soundList[this->_soundIndex].get()->pause();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundComponent::setVolume(float &volumeUpdate)
|
void SoundComponent::setVolume(float volumeUpdate)
|
||||||
{
|
{
|
||||||
if (!this->_isSoundLoad.at(this->_soundIndex))
|
if (volumeUpdate >= 0 && volumeUpdate <= 1) {
|
||||||
return;
|
|
||||||
if (volumeUpdate >= 0) {
|
|
||||||
this->volume = volumeUpdate;
|
this->volume = volumeUpdate;
|
||||||
this->_soundList[this->_soundIndex].get()->setVolume(this->volume);
|
for (auto &sound : _soundList)
|
||||||
|
sound.second->setVolume(volume);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundComponent::setPitch(float &pitch)
|
void SoundComponent::setPitch(float pitch)
|
||||||
{
|
{
|
||||||
if (!this->_isSoundLoad.at(this->_soundIndex))
|
if (!this->_isSoundLoad.at(this->_soundIndex))
|
||||||
return;
|
return;
|
||||||
@@ -88,4 +87,14 @@ namespace BBM
|
|||||||
return (this->_soundIndex);
|
return (this->_soundIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SoundComponent::turnDownVolume()
|
||||||
|
{
|
||||||
|
this->setVolume(SoundComponent::volume - 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SoundComponent::turnUpVolume()
|
||||||
|
{
|
||||||
|
this->setVolume(SoundComponent::volume + 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace WAL
|
} // namespace WAL
|
||||||
|
|||||||
@@ -42,10 +42,16 @@ namespace BBM
|
|||||||
void pauseSound();
|
void pauseSound();
|
||||||
|
|
||||||
//! @brief set Sound volume
|
//! @brief set Sound volume
|
||||||
void setVolume(float &);
|
void setVolume(float);
|
||||||
|
|
||||||
|
//! @brief volume -= 0.1
|
||||||
|
void turnDownVolume();
|
||||||
|
|
||||||
|
//! @brief volume += 0.1
|
||||||
|
void turnUpVolume();
|
||||||
|
|
||||||
//! @brief set pitch volume
|
//! @brief set pitch volume
|
||||||
void setPitch(float &);
|
void setPitch(float);
|
||||||
|
|
||||||
//! @brief is Sound playing
|
//! @brief is Sound playing
|
||||||
bool isPlaying();
|
bool isPlaying();
|
||||||
|
|||||||
@@ -409,7 +409,13 @@ namespace BBM
|
|||||||
auto &soundUp = scene->addEntity("sound up button")
|
auto &soundUp = scene->addEntity("sound up button")
|
||||||
.addComponent<PositionComponent>(1920 / 1.5, 1080 - 360, 0)
|
.addComponent<PositionComponent>(1920 / 1.5, 1080 - 360, 0)
|
||||||
.addComponent<Drawable2DComponent, RAY::Texture>("assets/buttons/button_plus.png")
|
.addComponent<Drawable2DComponent, RAY::Texture>("assets/buttons/button_plus.png")
|
||||||
.addComponent<OnClickComponent>()
|
.addComponent<SoundComponent>(sounds)
|
||||||
|
.addComponent<OnClickComponent>([](WAL::Entity &entity, WAL::Wal &)
|
||||||
|
{
|
||||||
|
auto &component = entity.getComponent<SoundComponent>();
|
||||||
|
|
||||||
|
component.turnUpVolume();
|
||||||
|
})
|
||||||
.addComponent<OnIdleComponent>([](WAL::Entity &entity, WAL::Wal &)
|
.addComponent<OnIdleComponent>([](WAL::Entity &entity, WAL::Wal &)
|
||||||
{
|
{
|
||||||
RAY::Texture *texture = dynamic_cast<RAY::Texture *>(entity.getComponent<Drawable2DComponent>().drawable.get());
|
RAY::Texture *texture = dynamic_cast<RAY::Texture *>(entity.getComponent<Drawable2DComponent>().drawable.get());
|
||||||
@@ -426,13 +432,19 @@ namespace BBM
|
|||||||
auto &soundDown = scene->addEntity("sound down button")
|
auto &soundDown = scene->addEntity("sound down button")
|
||||||
.addComponent<PositionComponent>(1920 / 3, 1080 - 360, 0)
|
.addComponent<PositionComponent>(1920 / 3, 1080 - 360, 0)
|
||||||
.addComponent<Drawable2DComponent, RAY::Texture>("assets/buttons/button_minus.png")
|
.addComponent<Drawable2DComponent, RAY::Texture>("assets/buttons/button_minus.png")
|
||||||
.addComponent<OnClickComponent>()
|
.addComponent<SoundComponent>(sounds)
|
||||||
.addComponent<OnIdleComponent>([](WAL::Entity &entity, WAL::Wal &)
|
.addComponent<OnIdleComponent>([](WAL::Entity &entity, WAL::Wal &)
|
||||||
{
|
{
|
||||||
RAY::Texture *texture = dynamic_cast<RAY::Texture *>(entity.getComponent<Drawable2DComponent>().drawable.get());
|
RAY::Texture *texture = dynamic_cast<RAY::Texture *>(entity.getComponent<Drawable2DComponent>().drawable.get());
|
||||||
|
|
||||||
texture->use("assets/buttons/button_minus.png");
|
texture->use("assets/buttons/button_minus.png");
|
||||||
})
|
})
|
||||||
|
.addComponent<OnClickComponent>([](WAL::Entity &entity, WAL::Wal &)
|
||||||
|
{
|
||||||
|
auto &component = entity.getComponent<SoundComponent>();
|
||||||
|
|
||||||
|
component.turnDownVolume();
|
||||||
|
})
|
||||||
.addComponent<OnHoverComponent>([](WAL::Entity &entity, WAL::Wal &)
|
.addComponent<OnHoverComponent>([](WAL::Entity &entity, WAL::Wal &)
|
||||||
{
|
{
|
||||||
RAY::Texture *texture = dynamic_cast<RAY::Texture *>(entity.getComponent<Drawable2DComponent>().drawable.get());
|
RAY::Texture *texture = dynamic_cast<RAY::Texture *>(entity.getComponent<Drawable2DComponent>().drawable.get());
|
||||||
|
|||||||
Reference in New Issue
Block a user