cocos2d-x 声音播放
#ifndef SGR_SoundPlay_h#define SGR_SoundPlay_h#include "cocos2d.h"class SoundPlay { public: SoundPlay(); ~SoundPlay();public: static SoundPlay& Instance() { static SoundPlay soundPlay; return soundPlay; }public: void play(); void stop();};#endif#include "SoundPlay.h"#include "SimpleAudioEngine.h"using namespace cocos2d;SoundPlay::SoundPlay(){ CocosDenshion::SimpleAudioEngine::sharedEngine() -> preloadBackgroundMusic("Sound/Dida.mp3");}SoundPlay::~SoundPlay(){ CocosDenshion::SimpleAudioEngine::sharedEngine() -> unloadEffect("Sound/Dida.mp3");}void SoundPlay::play(){ CocosDenshion::SimpleAudioEngine::sharedEngine()->playBackgroundMusic("Sound/Dida.mp3",true);}void SoundPlay::stop(){ CocosDenshion::SimpleAudioEngine::sharedEngine() -> stopBackgroundMusic(); }