This is wrapper classes collection for ADX2 LE for cocos2d-x.
#include "ADX2Manager.h"
bool init()
{
if (!Layer::init()) {
return false;
}
ADX2::Manager::initialize();
_cueSheet = CueSheet::create("sample.acf", "sample.acb");
_cueSheet->playCueByID(CRI_SAMPLE_BGM);
this->scheduleUpdate();
return true;
}
void update(float dt)
{
ADX2::Manager::getInstance()->update();
}
In ordinary way, you have to memory playback id of playing sounds.
CueSheet
instance have playback id of sounds by keywords.
You can stop or call some methods by keyword.
_cueSheet->playCueByID(CRI_SAMPLE_MAIN_MUSIC, "MainMusic");
int64_t currentTime = _cueSheet->getTime("MainMusic");
_cueSheet->stop("MainMusic");
If you would like to use same cue sheet globally, SharedCueSheet
may help you.
bool AppDelegate::applicationDidFinishLaunching() {
// get singleton shared sheet
auto sharedCueSheet = ADX2::SharedCueSheet::getInstance();
// initialize shared cue sheet by acf and acb
sharedCueSheet->initialize("sample.acf", "sample.acb");
// get cue sheet
sharedCueSheet->getCueSheet()->playCueByID(CRI_SAMPLE_BGM);
// purge shared cue sheet
SharedCueSheet::destroyInstance();
}
- copy
cocos2d
toexample
- Open
proj.ios/CcAdx2Basic.xcodeproj
- Build & Run