声音控制

开始播放音乐和音效后,你可能需要对它们进行一些控制,比如暂停、停止、恢复。这很容易完成,下面介绍:

暂停

  1. #include "AudioEngine.h"
  2. using namespace cocos2d::experimental;
  3. auto audioID = AudioEngine::play2d(...);
  4. // pause music.
  5. AudioEngine::pause(audioID);
  6. // pause all sound effects.
  7. AudioEngine::pauseAll();

停止

  1. #include "AudioEngine.h"
  2. using namespace cocos2d::experimental;
  3. auto audioID = AudioEngine::play2d(...);
  4. // stop music.
  5. AudioEngine::stop(audioID);
  6. // stops all running sound effects.
  7. AudioEngine::stopAll();

恢复

  1. #include "AudioEngine.h"
  2. using namespace cocos2d::experimental;
  3. auto audioID = AudioEngine::play2d(...);
  4. // resume music.
  5. AudioEngine::resume(audioID);
  6. // resume all sound effects.
  7. AudioEngine::resumeAll();