Cocos2d-X 学习笔记 17 Cocos2dx 下对sqlite3 的简单封装

Cocos2d-X 学习笔记 17 Cocos2dx 下对sqlite3 的简单封装,第1张

概述typedef struct {       unsigned int soundId;       const char* soundFilePath;   }Sound;         typedef struct {        const char* musicFilePath;   } Music;      /*   * 注意,Andoird下面只支持.ogg   *   */   typedefstruct{ unsignedintsoundID; constchar*soundfilePath; }Sound; char*musicfilePath; }Music; /* *注意,Andoird下面只支持.ogg * */ staticMusicbgMusic= { "audio/mainbgmusic.ogg" }; staticSoundtestSound= 0, "audio/clicksound.ogg" }; classAudioManager public: /*注意,此方法在进入游戏前调用*/ staticvoIDinit(); /*预加载*/ voIDpreLoadBgMusic(Music&music); voIDpreLoadSound(Sound&sound); /*播放*/ voIDplayMusic(Music&music,boolloop=true); voIDplaySound(Sound&sound,153); background-color:inherit; Font-weight:bold">false); /*暂停*/ voIDpauseMusic(Music&music); voIDpauseSound(Sound&sound); /*停止*/ voIDstopMusic(Music&music,87); background-color:inherit; Font-weight:bold">boolrelease=voIDstopSound(Sound&sound); voIDstopAllSound(); /*恢复*/ voIDresumeMusic(); /*全部结束*/ voIDend(); </pre><br> <pre></pre> <br> <prename="code"class="cpp"><prename="code"class="cpp">voIDAudioManager::init() { /*例子*/ preLoadBgMusic(bgMusic); preLoadSound(testSound); } /********************************************************* 一些方法的封装 *********************************************************/ voIDAudioManager::preLoadBgMusic(Music&music) usingnamespaceCocosDenshion; namespacecocos2d; music.musicfilePath=CCfileUtils::sharedfileUtils()->fullPathFromrelativePath(music.musicfilePath); cclOG(music.musicfilePath); SimpleAudioEngine::sharedEngine()->preloadBackgroundMusic(music.musicfilePath); voIDAudioManager::preLoadSound(Sound&sound) namespaceCocosDenshion; namespacecocos2d; sound.soundfilePath=CCfileUtils::sharedfileUtils()->fullPathFromrelativePath(sound.soundfilePath); SimpleAudioEngine::sharedEngine()->preloadEffect(sound.soundfilePath); voIDAudioManager::playMusic(Music&music,87); background-color:inherit; Font-weight:bold">boolloop/*default=true*/) /*先判断是否已经在播放,如果在播放,则直接返回*/ if(SimpleAudioEngine::sharedEngine()->isBackgroundMusicPlaying()){ return; } SimpleAudioEngine::sharedEngine()->playBackgroundMusic(music.musicfilePath,loop); voIDAudioManager::playSound(Sound&sound,0); background-color:inherit">/*defaultisfalse*/) sound.soundID=SimpleAudioEngine::sharedEngine()->playEffect(sound.soundfilePath,loop); voIDAudioManager::pauseMusic(Music&music) SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic(); voIDAudioManager::pauseSound(Sound&sound) SimpleAudioEngine::sharedEngine()->pauseEffect(sound.soundID); voIDAudioManager::stopMusic(Music&music,87); background-color:inherit; Font-weight:bold">boolrelease/*defaultistrue*/) SimpleAudioEngine::sharedEngine()->stopBackgroundMusic(release); voIDAudioManager::stopSound(Sound&sound) SimpleAudioEngine::sharedEngine()->stopEffect(sound.soundID); voIDAudioManager::stopAllSound() SimpleAudioEngine::sharedEngine()->stopAllEffects(); voIDAudioManager::resumeMusic() SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic(); voIDAudioManager::end() SimpleAudioEngine::sharedEngine()->end(); 注意: 进入游戏后,开始初始化资源调用 /*初始化游戏音效*/ AudioManager::init();

游戏切换到后台调用: AudioManager::pauseMusic(bgMusic); 游戏重新切换回前台 AudioManager::resumeMusic(); 总结

以上是内存溢出为你收集整理的Cocos2d-X 学习笔记 17 Cocos2dx 下对sqlite3 的简单封装全部内容,希望文章能够帮你解决Cocos2d-X 学习笔记 17 Cocos2dx 下对sqlite3 的简单封装所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1005806.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-22
下一篇 2022-05-22

发表评论

登录后才能评论

评论列表(0条)

保存