LibD/src/Sound/SoundEffect.cpp
Tamir Atias 7aa8d9adb2 [Add] Sound effects.
[Add] Player walking sounds.
2012-04-12 19:50:19 +03:00

33 lines
635 B
C++

#include <SDL/SDL_mixer.h>
#include "SoundEffect.h"
ResourceManager<SoundEffect> sfxManager;
SoundEffect::SoundEffect() {
_chunk = NULL;
}
SoundEffect::~SoundEffect() {
if(_chunk) {
Mix_FreeChunk(_chunk);
_chunk = NULL;
}
}
bool SoundEffect::Load(const std::string& filename) {
_chunk = Mix_LoadWAV(filename.c_str());
return _chunk != NULL;
}
void SoundEffect::Play(SoundEffect* effect, int channel, int loops) {
Mix_PlayChannel(channel, effect->_chunk, loops);
}
void SoundEffect::Stop(int channel) {
Mix_HaltChannel(channel);
}
bool SoundEffect::IsPlaying(int channel) {
return Mix_Playing(channel);
}