- 声音控制
- 暂停
- 停止
- 恢复
声音控制
开始播放音乐和音效后,你可能需要对它们进行一些控制,比如暂停、停止、恢复。这很容易完成,下面介绍:
暂停
C++
#include "SimpleAudioEngine.h"
using namespace CocosDenshion;
auto audio = SimpleAudioEngine::getInstance();
// pause background music.
audio->pauseBackgroundMusic();
// pause a sound effect.
audio->pauseEffect();
// pause all sound effects.
audio->pauseAllEffects();
停止
C++
#include "SimpleAudioEngine.h"
using namespace CocosDenshion;
auto audio = SimpleAudioEngine::getInstance();
// stop background music.
audio->stopBackgroundMusic();
// stop a sound effect.
audio->stopEffect();
// stops all running sound effects.
audio->stopAllEffects();
恢复
C++
#include "SimpleAudioEngine.h"
using namespace CocosDenshion;
auto audio = SimpleAudioEngine::getInstance();
// resume background music.
audio->resumeBackgroundMusic();
// resume a sound effect.
audio->resumeEffect();
// resume all sound effects.
audio->resumeAllEffects();
原文: http://docs.cocos.com/cocos2d-x/manual/zh/audio/operations.html