Dragonfly 4.20
A text-based game engine
Sound.h
1///
2/// The sound
3///
4
5#ifndef __SOUND_H__
6#define __SOUND_H__
7
8// System includes.
9#include <string>
10#include <SFML/Audio.hpp>
11
12namespace df {
13
14class Sound {
15
16 private:
17#ifndef NO_SOUND
18 sf::Sound m_sound; ///< SFML sound.
19 sf::SoundBuffer m_sound_buffer; ///< SFML sound buffer associated with sound.
20#endif
21 std::string m_label; ///< Text label to identify sound.
22
23 public:
24 Sound();
25 ~Sound();
26
27 /// Load sound buffer from file.
28 /// Return 0 if ok, else -1.
29 int loadSound(std::string filename);
30
31 /// Set label associated with sound.
32 void setLabel(std::string new_label);
33
34 /// Get label associated with sound.
35 std::string getLabel() const;
36
37 /// Play sound.
38 /// If loop is true, repeat play when done.
39 void play(bool loop=false);
40
41 /// Stop sound.
42 void stop();
43
44 /// Pause sound.
45 void pause();
46
47 /// Return SFML sound.
48#ifndef NO_SOUND
49 sf::Sound getSound() const;
50#endif
51};
52
53} // end of namespace df
54#endif // __SOUND_H__
Definition: Sound.h:14
void setLabel(std::string new_label)
Set label associated with sound.
void pause()
Pause sound.
sf::SoundBuffer m_sound_buffer
SFML sound buffer associated with sound.
Definition: Sound.h:19
int loadSound(std::string filename)
Load sound buffer from file.
sf::Sound getSound() const
Return SFML sound.
sf::Sound m_sound
SFML sound.
Definition: Sound.h:18
std::string getLabel() const
Get label associated with sound.
std::string m_label
Text label to identify sound.
Definition: Sound.h:21
void play(bool loop=false)
Play sound.
void stop()
Stop sound.
An animation for a sprite.
Definition: Animation.h:15