cocos2dx学习日记四:SimpleAudioEngine使用

前端之家收集整理的这篇文章主要介绍了cocos2dx学习日记四:SimpleAudioEngine使用前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

cocos2dx中可以使用SimpleAudioEngine音频引擎添加和管理项目中的音频和特效,SimpleAudioEngine是一个共享的单例对象,

1,SimpleAudioEngine简介

SimpleAudioEngine在扩展库libAudio中,使用的时候需添加进项目中,声明在命名空间namespace:CocosDenshion中。

2,SimpleAudioEngine方法

播放:

SimpleAudioEngine::getInstance()->playBackgroundMusic("background.mp3",true);

SimpleAudioEngine::getInstance()->playBackgroundMusic("background.mp3",false);

SimpleAudioEngine::getInstance()->playEffect("background.mp3",false,1.0,1.0);

暂停:

SimpleAudioEngine::getInstance()->pauseBackgroundMusic();

SimpleAudioEngine::getInstance()->pauseEffect();

SimpleAudioEngine::getInstance()->pauseAllEffects();

恢复:

SimpleAudioEngine::getInstance()->resumeBackgroundMusic();

SimpleAudioEngine::getInstance()->resumeEffect();

SimpleAudioEngine::getInstance()->resumeAllEffects();

停止:

SimpleAudioEngine::getInstance()->stopBackgroundMusic();

SimpleAudioEngine::getInstance()->stopEffect();

SimpleAudioEngine::getInstance()->stopAllEffects();







原文链接:https://www.f2er.com/cocos2dx/343934.html

猜你在找的Cocos2d-x相关文章