#include "SoundMaster.h"
#include "cocos2d.h"
#include "SimpleAudioEngine.h"
USING_NS_CC;

const int amountOfSounds = 2;

SoundMaster::SoundMaster(void)
{
}


SoundMaster::~SoundMaster(void)
{
	auto audio = CocosDenshion::SimpleAudioEngine::getInstance();
	audio->stopBackgroundMusic();
	audio->end();
}

void SoundMaster::play()
{
	auto audio = CocosDenshion::SimpleAudioEngine::getInstance();

	if (!audio->isBackgroundMusicPlaying())
	{
		int sound = rand()%amountOfSounds;
		std::ostringstream s;
		s << "sounds\\" << sound <<".mp3";
		audio->playBackgroundMusic(s.str().c_str(), false);
	}
}

void SoundMaster::stop()
{
	auto audio = CocosDenshion::SimpleAudioEngine::getInstance();

	audio->stopBackgroundMusic();
}