Class for handling background music.
More...
#include <BGM.hpp>
|
| | BGM (const std::string &path) |
| | Constructor that initializes the BGM object and loads the music from the specified file path. More...
|
| |
|
| BGM (const BGM &)=delete |
| | Deleted copy constructor to prevent copying of BGM objects.
|
| |
|
BGM & | operator= (const BGM &)=delete |
| | Deleted copy assignment operator to prevent copying of BGM objects.
|
| |
| int | GetVolume () const |
| | Retrieves the current volume of the background music. More...
|
| |
| void | SetVolume (int volume) |
| | Sets the volume of the background music. More...
|
| |
| void | LoadMedia (const std::string &path) |
| | Loads the background music from the specified file path. More...
|
| |
| void | VolumeUp (int step=1) |
| | Increases the volume of the background music by one. More...
|
| |
| void | VolumeDown (int step=1) |
| | Decreases the volume of the background music by one. More...
|
| |
| void | Play (int loop=-1) |
| | Plays the background music. More...
|
| |
| void | FadeIn (int tick, int loop=-1) |
| | Fades in the background music gradually. More...
|
| |
| void | FadeOut (int tick) |
| | Fades out the background music gradually. More...
|
| |
| void | Pause () |
| | Pauses the currently playing background music. More...
|
| |
| void | Resume () |
| | Resumes the paused background music. More...
|
| |
Class for handling background music.
- Note
- There can be only one BGM object playing at a time. If a BGM object is playing and another BGM object is played, the previous one will stop playing.
- See also
- Util::SFX
◆ BGM()
| Util::BGM::BGM |
( |
const std::string & |
path | ) |
|
|
explicit |
Constructor that initializes the BGM object and loads the music from the specified file path.
- Parameters
-
| path | The file path of the background music to be loaded. |
◆ FadeIn()
| void Util::BGM::FadeIn |
( |
int |
tick, |
|
|
int |
loop = -1 |
|
) |
| |
Fades in the background music gradually.
- Parameters
-
| tick | The duration of the fade-in effect, in milliseconds. |
| loop | The number of times the music will loop after the fade-in is complete.
A value of -1 means it will loop indefinitely. |
◆ FadeOut()
| void Util::BGM::FadeOut |
( |
int |
tick | ) |
|
Fades out the background music gradually.
- Parameters
-
| tick | The duration of the fade-out effect, in milliseconds. |
◆ GetVolume()
| int Util::BGM::GetVolume |
( |
| ) |
const |
Retrieves the current volume of the background music.
- Returns
- The current volume of the background music.
◆ LoadMedia()
| void Util::BGM::LoadMedia |
( |
const std::string & |
path | ) |
|
Loads the background music from the specified file path.
- Parameters
-
| path | The file path of the background music to be loaded. |
◆ Pause()
| void Util::BGM::Pause |
( |
| ) |
|
Pauses the currently playing background music.
- Note
- This function has no effect if there is no background music currently playing.
◆ Play()
| void Util::BGM::Play |
( |
int |
loop = -1 | ) |
|
Plays the background music.
- Parameters
-
| loop | The number of times the music will loop.
A value of -1 means it will loop indefinitely.
A non-negative value means it will loop that many times.
Default value: -1 |
- Note
- Calling this function stops any currently playing music and plays.
◆ Resume()
| void Util::BGM::Resume |
( |
| ) |
|
Resumes the paused background music.
- Note
- This function has no effect if there is no paused background music.
◆ SetVolume()
| void Util::BGM::SetVolume |
( |
int |
volume | ) |
|
Sets the volume of the background music.
- Parameters
-
| volume | The desired volume level for the background music. The valid range is [0, 128].
A value of 0 mutes the music, and a value of 128 sets the maximum volume. |
◆ VolumeDown()
| void Util::BGM::VolumeDown |
( |
int |
step = 1 | ) |
|
Decreases the volume of the background music by one.
- Parameters
-
| step | The amount to decrease the volume by. |
◆ VolumeUp()
| void Util::BGM::VolumeUp |
( |
int |
step = 1 | ) |
|
Increases the volume of the background music by one.
- Parameters
-
| step | The amount to increase the volume by. |
The documentation for this class was generated from the following file: