Dragonfly  4.3
A text-based game engine
Music.h
1 ///
2 /// The music
3 ///
4 
5 #ifndef __MUSIC_H__
6 #define __MUSIC_H__
7 
8 // System includes.
9 #include <string>
10 #include <SFML/Audio.hpp>
11 
12 namespace df {
13 
14 class Music {
15 
16  private:
17  sf::Music m_music; ///< The SFML music.
18  std::string m_label; ///< Text label to identify music.
19  Music(Music const&); ///< SFML doesn't allow music copy.
20  void operator=(Music const&); ///< SFML doesn't allow music assignment.
21 
22  public:
23  Music();
24 
25  /// Associate music buffer with file.
26  /// Return 0 if ok, else -1.
27  int loadMusic(std::string filename);
28 
29  /// Set label associated with music.
30  void setLabel(std::string new_label);
31 
32  /// Get label associated with music.
33  std::string getLabel() const;
34 
35  /// Play music.
36  /// If loop is true, repeat play when done.
37  void play(bool loop=true);
38 
39  /// Stop music.
40  void stop();
41 
42  /// Pause music.
43  void pause();
44 
45  /// Return pointer to SFML music.
46  sf::Music *getMusic();
47 };
48 
49 } // end of namespace df
50 #endif // __MUSIC_H__
std::string m_label
Text label to identify music.
Definition: Music.h:18
void operator=(Music const &)
SFML doesn&#39;t allow music assignment.
Definition: Music.h:14
void pause()
Pause music.
A 2-d bounding box.
Definition: Box.h:10
int loadMusic(std::string filename)
Associate music buffer with file.
sf::Music m_music
The SFML music.
Definition: Music.h:17
sf::Music * getMusic()
Return pointer to SFML music.
void play(bool loop=true)
Play music.
void stop()
Stop music.
void setLabel(std::string new_label)
Set label associated with music.
std::string getLabel() const
Get label associated with music.