Dragonfly 4.20
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
12namespace df {
13
14class Music {
15
16 private:
17#ifndef NO_SOUND
18 sf::Music m_music; ///< The SFML music.
19#endif
20 std::string m_label; ///< Text label to identify music.
21 Music(Music const&); ///< SFML doesn't allow music copy.
22 void operator=(Music const&); ///< SFML doesn't allow music assignment.
23
24 public:
25 Music();
26
27 /// Associate music buffer with file.
28 /// Return 0 if ok, else -1.
29 int loadMusic(std::string filename);
30
31 /// Set label associated with music.
32 void setLabel(std::string new_label);
33
34 /// Get label associated with music.
35 std::string getLabel() const;
36
37 /// Play music.
38 /// If loop is true, repeat play when done.
39 void play(bool loop=true);
40
41 /// Stop music.
42 void stop();
43
44 /// Pause music.
45 void pause();
46
47 /// Return pointer to SFML music.
48#ifndef NO_SOUND
49 sf::Music *getMusic();
50#endif
51};
52
53} // end of namespace df
54#endif // __MUSIC_H__
Definition: Music.h:14
std::string getLabel() const
Get label associated with music.
std::string m_label
Text label to identify music.
Definition: Music.h:20
Music(Music const &)
SFML doesn't allow music copy.
void operator=(Music const &)
SFML doesn't allow music assignment.
void pause()
Pause music.
void setLabel(std::string new_label)
Set label associated with music.
sf::Music m_music
The SFML music.
Definition: Music.h:18
void play(bool loop=true)
Play music.
sf::Music * getMusic()
Return pointer to SFML music.
int loadMusic(std::string filename)
Associate music buffer with file.
void stop()
Stop music.
An animation for a sprite.
Definition: Animation.h:15