【问题标题】:Play sound in Sequence in cocos2d在 cocos2d 中按顺序播放声音
【发布时间】:2012-02-16 16:04:57
【问题描述】:

如何在 cocos2d 中按顺序播放声音有没有人知道例如我有三个类似的声音

[[SimpleAudioEngine sharedEngine] playEffect:[CommanMethods GetCompleteSoundPath:objplate.OrderOneSound]];

[[SimpleAudioEngine sharedEngine] playEffect:[CommanMethods GetCompleteSoundPath:objplate.WithSound]];

[[SimpleAudioEngine sharedEngine] playEffect:[CommanMethods GetCompleteSoundPath:objplate.OrderTwoSound]];

这是音效播放的代码,当一个停止时如何播放,然后再播放一个

【问题讨论】:

  • 您可以使用 CCSequence 为 Sound 播放效果!这将是更好的方式!

标签: iphone cocos2d-iphone xcode4.2 simpleaudioengine


【解决方案1】:
CCSequence* sequence = [CCSequence actions: 
                                [CCCallBlock actionWithBlock:^(void)
                                 { 
                                     [[SimpleAudioEngine sharedEngine] playEffect:[CommanMethods GetCompleteSoundPath:objplate.OrderOneSound]];
                                 }],
                                [CCDelayTime actionWithDuration:3],
                                [CCCallBlock actionWithBlock:^(void)
                                 { 
                                     [[SimpleAudioEngine sharedEngine] playEffect:[CommanMethods GetCompleteSoundPath:objplate.WithSound]];
                                 }],
                                [CCDelayTime actionWithDuration:3],
                                [CCCallBlock actionWithBlock:^(void)
                                 { 
                                     [[SimpleAudioEngine sharedEngine] playEffect:[CommanMethods GetCompleteSoundPath:objplate.OrderTwoSound]];
                                 }],
                                nil];
[self runAction:sequence];

这种方式可以解决您的问题,但唯一的缺点是您必须自己插入延迟时间。希望它适用于您的情况。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-05
    • 1970-01-01
    • 2011-08-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-03
    相关资源
    最近更新 更多