mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-06-05 10:59:48 +00:00
add updateMusicStream + musicSystem
This commit is contained in:
@@ -7,49 +7,59 @@
|
||||
|
||||
namespace BBM
|
||||
{
|
||||
MusicComponent::MusicComponent(WAL::Entity &entity, const std::string &musicPath)
|
||||
: WAL::Component(entity),
|
||||
_musicPath(musicPath),
|
||||
_music(RAY::Audio::Music(musicPath))
|
||||
{
|
||||
}
|
||||
MusicComponent::MusicComponent(WAL::Entity &entity, const std::string &musicPath)
|
||||
: WAL::Component(entity),
|
||||
_musicPath(musicPath),
|
||||
_music(RAY::Audio::Music(musicPath))
|
||||
{
|
||||
}
|
||||
|
||||
WAL::Component *MusicComponent::clone(WAL::Entity &entity) const
|
||||
WAL::Component *MusicComponent::clone(WAL::Entity &entity) const
|
||||
{
|
||||
return new MusicComponent(entity, this->_musicPath);
|
||||
}
|
||||
|
||||
void MusicComponent::loadMusic(void)
|
||||
{
|
||||
if (!this->_music.isPlaying())
|
||||
this->_music.play();
|
||||
}
|
||||
void MusicComponent::playMusic(void)
|
||||
{
|
||||
if (!this->_music.isPlaying()) {
|
||||
this->_music.play();
|
||||
this->_music.updateMusicStream();
|
||||
}
|
||||
}
|
||||
|
||||
void MusicComponent::unloadMusic(void)
|
||||
{
|
||||
if (!this->_music.isPlaying())
|
||||
this->_music.stop();
|
||||
}
|
||||
void MusicComponent::stopMusic(void)
|
||||
{
|
||||
if (!this->_music.isPlaying()) {
|
||||
this->_music.stop();
|
||||
this->_music.updateMusicStream();
|
||||
}
|
||||
}
|
||||
|
||||
void MusicComponent::pauseMusic(void)
|
||||
{
|
||||
this->_music.pause();
|
||||
}
|
||||
void MusicComponent::pauseMusic(void)
|
||||
{
|
||||
this->_music.pause();
|
||||
}
|
||||
|
||||
void MusicComponent::setVolume(float &volume)
|
||||
{
|
||||
if (volume >= 0)
|
||||
this->_music.setVolume(volume);
|
||||
}
|
||||
void MusicComponent::setVolume(float &volumeUpdate)
|
||||
{
|
||||
if (volumeUpdate >= 0) {
|
||||
this->_music.setVolume(volume);
|
||||
}
|
||||
}
|
||||
|
||||
void MusicComponent::setPitch(float &pitch)
|
||||
{
|
||||
this->_music.setPitch(pitch);
|
||||
}
|
||||
{
|
||||
this->_music.setPitch(pitch);
|
||||
}
|
||||
|
||||
bool MusicComponent::isPlaying(void)
|
||||
{
|
||||
return (this->_music.isPlaying());
|
||||
}
|
||||
{
|
||||
return (this->_music.isPlaying());
|
||||
}
|
||||
|
||||
void MusicComponent::updateMusicStream(void)
|
||||
{
|
||||
this->_music.updateMusicStream();
|
||||
}
|
||||
|
||||
} // namespace WAL
|
||||
|
||||
@@ -14,11 +14,11 @@ namespace BBM
|
||||
class MusicComponent : public WAL::Component
|
||||
{
|
||||
public:
|
||||
//! @brief load music
|
||||
void loadMusic();
|
||||
//! @brief start music
|
||||
void playMusic();
|
||||
|
||||
//! @brief unload music
|
||||
void unloadMusic();
|
||||
//! @brief stop music
|
||||
void stopMusic();
|
||||
|
||||
//! @brief put music on hold
|
||||
void pauseMusic();
|
||||
@@ -31,7 +31,8 @@ namespace BBM
|
||||
|
||||
//! @brief is music playing
|
||||
bool isPlaying(void);
|
||||
|
||||
|
||||
void updateMusicStream(void);
|
||||
//! @inherit
|
||||
WAL::Component *clone(WAL::Entity &entity) const override;
|
||||
//! @brief Create a new MusicComponent at a certain Music
|
||||
@@ -42,7 +43,8 @@ namespace BBM
|
||||
~MusicComponent() override = default;
|
||||
//! @brief A Music component is not assignable
|
||||
MusicComponent &operator=(const MusicComponent &) = delete;
|
||||
|
||||
//! @brief Volume of the muisc
|
||||
float volume = 1;
|
||||
private:
|
||||
//! @brief music of this entity
|
||||
RAY::Audio::Music _music;
|
||||
|
||||
Reference in New Issue
Block a user