读书人

cocos2d-x 声音播发

发布时间: 2012-06-27 14:20:09 作者: rapoo

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();    }

读书人网 >操作系统

热点推荐