YAPOG
0.0.1
Yet Another Pokemon Online Game
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
AudioManager.cpp
Go to the documentation of this file.
1
#include "
YAPOG/Audio/AudioManager.hpp
"
2
#include "
YAPOG/System/Error/Exception.hpp
"
3
#include "
YAPOG/System/StringHelper.hpp
"
4
#include "
YAPOG/Content/ContentManager.hpp
"
5
6
namespace
yap
7
{
8
AudioManager::AudioManager
()
9
: currentMusic_ (nullptr)
10
, previousMusic_ (nullptr)
11
, currentSound_ (new sf::Sound ())
12
{
13
}
14
15
AudioManager::~AudioManager
()
16
{
17
}
18
19
AudioManager
&
AudioManager::Instance
()
20
{
21
static
AudioManager
instance_;
22
23
return
instance_;
24
}
25
26
void
AudioManager::PlayMusic
(
const
String
& musicName,
bool
fromBegin)
27
{
28
if
(
currentMusic_
!=
nullptr
)
29
{
30
currentMusic_
->pause ();
31
previousMusic_
=
currentMusic_
;
32
}
33
34
currentMusic_
= &
ContentManager::Instance
().LoadMusic (musicName);
35
36
currentMusic_
->setLoop (
true
);
37
38
if
(fromBegin)
39
currentMusic_
->stop ();
40
41
currentMusic_
->play ();
42
}
43
44
void
AudioManager::PlaySound
(
const
String
& soundName)
45
{
46
if
(
currentSound_
!=
nullptr
)
47
currentSound_
->stop ();
48
49
currentSound_
->setBuffer (
50
ContentManager::Instance
().LoadSoundBuffer (soundName));
51
52
currentSound_
->play ();
53
}
54
55
void
AudioManager::ResumePreviousMusic
()
56
{
57
if
(
previousMusic_
!=
nullptr
)
58
{
59
void
* tmp =
currentMusic_
;
60
61
currentMusic_
->pause ();
62
previousMusic_
->play ();
63
currentMusic_
=
previousMusic_
;
64
previousMusic_
= (sf::Music*)tmp;
65
}
66
}
67
68
}
// namespace yap
YAPOG
src
YAPOG
Audio
AudioManager.cpp
Generated on Mon Sep 17 2012 22:24:24 for YAPOG by
1.8.1.1