• 播放背景音乐/音效

    播放背景音乐/音效

    通过下面的方式,播放一个音频文件作为背景音乐或者音效,可以控制音乐是否循环播放。

    1. #include "AudioEngine.h"
    2. using namespace cocos2d::experimental;
    3. // set the background music and continuously play it.
    4. auto backgroundAudioID = AudioEngine::play2d("mymusic.mp3", true);
    5. // set the music and play it just once.
    6. auto soundEffectID = AudioEngine::play2d("gameeffect.mp3", false);