我正在使用Cocos2d-x库和Cocosdenshion AudioEngine开发一个简单的视频游戏。

我可以使用SharedAudioEngine的playEffect方法播放单个声音,但是我想做的是按顺序ordeq播放多个声音。

但是我不知道从哪里开始。我尝试创建一个 Action 序列,该 Action 序列将使用选择器调用该方法,但似乎不起作用。

最佳答案

    write number of Function equal to the Number of Sound effects.
    like this
    Function1(){
        CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("Sound1.mp3");
    }
    Function2{
    CocosDenshion::SimpleAudioEngine::sharedEngine()->stopAllEffects();
        CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("Sound2.mp3");
    }
    Function3{
    CocosDenshion::SimpleAudioEngine::sharedEngine()->stopAllEffects();
        CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("Sound3.mp3");
    }
CCSequence *seq = CCSequence::create(Func1,func2,func3,NULL);
CCRepeatForever *repeat = CCRepeatForever::create(seq);
this->runAction(repeat);

关于c++ - 用CocosDenshion顺序播放声音?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/12509404/

10-11 22:49