Dragonfly  4.3
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 
12 namespace df {
13 
14 class Sound {
15 
16  private:
17  sf::Sound m_sound; ///< SFML sound.
18  sf::SoundBuffer m_sound_buffer; ///< SFML sound buffer associated with sound.
19  std::string m_label; ///< Text label to identify sound.
20 
21  public:
22  Sound();
23  ~Sound();
24 
25  /// Load sound buffer from file.
26  /// Return 0 if ok, else -1.
27  int loadSound(std::string filename);
28 
29  /// Set label associated with sound.
30  void setLabel(std::string new_label);
31 
32  /// Get label associated with sound.
33  std::string getLabel() const;
34 
35  /// Play sound.
36  /// If loop is true, repeat play when done.
37  void play(bool loop=false);
38 
39  /// Stop sound.
40  void stop();
41 
42  /// Pause sound.
43  void pause();
44 
45  /// Return SFML sound.
46  sf::Sound getSound() const;
47 };
48 
49 } // end of namespace df
50 #endif // __SOUND_H__
void play(bool loop=false)
Play sound.
sf::Sound m_sound
SFML sound.
Definition: Sound.h:17
void stop()
Stop sound.
std::string getLabel() const
Get label associated with sound.
Definition: Sound.h:14
void pause()
Pause sound.
A 2-d bounding box.
Definition: Box.h:10
std::string m_label
Text label to identify sound.
Definition: Sound.h:19
void setLabel(std::string new_label)
Set label associated with sound.
int loadSound(std::string filename)
Load sound buffer from file.
sf::Sound getSound() const
Return SFML sound.
sf::SoundBuffer m_sound_buffer
SFML sound buffer associated with sound.
Definition: Sound.h:18