Cocos2d-x v3 C++ Tutorial … 流すだけでそんなに時間かからないだろう
…と思っていた自分が恥ずかしい..
とりあえず Sound系の残りを流す。
Cocos2d-x v3 C++ Tutorial 29 – Setting Sound Effect Volume
https://www.youtube.com/watch?v=ZPsJJhimM28
Cocos2d-x v3 C++ Tutorial 30 – Stopping Sound Effect
https://www.youtube.com/watch?v=pBTsA7U2rSU
Cocos2d-x v3 C++ Tutorial 31 – Playing Music
https://www.youtube.com/watch?v=PpvQQKwCdi4
Cocos2d-x v3 C++ Tutorial 32 – Stopping Music
https://www.youtube.com/watch?v=Q3w3v_Iwsn0
Cocos2d x v3 C++ Tutorial 33 – Pausing and Resuming Music
https://www.youtube.com/watch?v=EepI2aVSkcQ
Cocos2d-x v3 C++ Tutorial 34 – Setting Music Volume
https://www.youtube.com/watch?v=XmU7VpwNT50
まぁ、BGM/SE の再生・一時停止・再開・ボリューム … 動く事の確認です。
CallFunction のラムダ式の記述がすごい気になっていたので遊べてよかった ^^
[]() … の部分について知識を付けたい…
//Tutorial 27 - 34
{
const std::function<void ()> func;
auto action = CCSequence::create(
CallFunc::create([=]() -> void {
//Tutorial 28
CocosDenshion::SimpleAudioEngine::getInstance()->playEffect(fileName.c_str(), true);
}),
DelayTime::create(2.5f),
CallFunc::create([]() -> void {
//Tutorial 29
CocosDenshion::SimpleAudioEngine::getInstance()->setEffectsVolume(0.1f);
}),
DelayTime::create(2.5f),
CallFunc::create([]() -> void {
//Tutorial 30
CocosDenshion::SimpleAudioEngine::getInstance()->stopAllEffects();
}),
CallFunc::create([]() -> void {
CocosDenshion::SimpleAudioEngine::getInstance()->setEffectsVolume(1.0f);
}),
CallFunc::create([=]() -> void {
//Tutorial 31
CocosDenshion::SimpleAudioEngine::getInstance()->playBackgroundMusic(bgmFile.c_str());
}),
DelayTime::create(1.0f),
CallFunc::create([]() -> void {
//Tutorial 32
CocosDenshion::SimpleAudioEngine::getInstance()->stopBackgroundMusic();
}),
DelayTime::create(0.5f),
CallFunc::create([=]() -> void {
CocosDenshion::SimpleAudioEngine::getInstance()->playBackgroundMusic(bgmFile.c_str());
} ),
DelayTime::create(0.5f),
CallFunc::create([]() -> void {
//Tutorial 33 Pause
CocosDenshion::SimpleAudioEngine::getInstance()->pauseBackgroundMusic();
} ),
DelayTime::create(0.5f),
CallFunc::create([]() -> void {
//Tutorial 33 Resume
CocosDenshion::SimpleAudioEngine::getInstance()->resumeBackgroundMusic();
} ),
//アクションで徐々にボリュームを落としてみる
Repeat::create(Sequence::create(DelayTime::create(0.25f),
CallFunc::create([]() -> void {
float value = CocosDenshion::SimpleAudioEngine::getInstance()->getBackgroundMusicVolume();
{
value -= 0.1f;
if (value < 0.1f)
{
value = 0.1f;
}
}
//Tutorial 34
CocosDenshion::SimpleAudioEngine::getInstance()->setBackgroundMusicVolume(value);
}),
nullptr), 10),
nullptr);
this->runAction(action);
}