cocos2d-x的声音控制

声音控制SimpleAudioEngine是单例,以下是其方法。
[cpp]  view plain copy
  1. //获得SimpleAudioEngine的实例  
  2. static SimpleAudioEngine* sharedEngine();  
  3. //提前载入音频  
  4. void preloadBackgroundMusic(const char* pszFilePath);  
  5. //播放背景音乐,是否循环播放  
  6. void playBackgroundMusic(const char* pszFilePath, bool bLoop = false);  
  7. //停止背景音乐  
  8. void stopBackgroundMusic(bool bReleaseData = false);  
  9. //暂停背景音乐  
  10. void pauseBackgroundMusic();  
  11. //恢复背景音乐  
  12. void resumeBackgroundMusic();  
  13. //重新播放背景音乐  
  14. void rewindBackgroundMusic();  
  15. //是否正在播放背景音乐  
  16. bool isBackgroundMusicPlaying();  
  17. //获得背景音乐音量  
  18. float getBackgroundMusicVolume();  
  19. //设置背景音乐音量  
  20. void setBackgroundMusicVolume(float volume);  
  21. //获得音效音量  
  22. float getEffectsVolume();  
  23. //设置音效音量  
  24. void setEffectsVolume(float volume);  
  25. //播放音效,是否循环播放,返回一个内部维护的ID号  
  26. unsigned int playEffect(const char* pszFilePath, bool bLoop = false);  
  27. //暂停ID音效  
  28. void pauseEffect(unsigned int nSoundId);  
  29. //暂停所有音效  
  30. void pauseAllEffects();  
  31. //恢复ID音效  
  32. void resumeEffect(unsigned int nSoundId);  
  33. //恢复所有音效  
  34. void resumeAllEffects();  
  35. //停止ID音效  
  36. void stopEffect(unsigned int nSoundId);  
  37. //停止所有音效  
  38. void stopAllEffects();  
  39. //提前载入音效  
  40. void preloadEffect(const char* pszFilePath);  
  41. //释放音效  
  42. void unloadEffect(const char* pszFilePath);  

增大音量


[cpp]  view plain copy
  1. SimpleAudioEngine::sharedEngine()->setBackgroundMusicVolume(SimpleAudioEngine::sharedEngine()->getBackgroundMusicVolume() + 0.1f);  
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值