在cocos2d中按顺序播放声音

时间:2012-01-23 09:22:56

标签: iphone cocos2d-iphone xcode4.2 simpleaudioengine

如何按顺序在cocos2d中播放声音,任何身体都有任何想法,例如我有三个声音

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

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

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

这是声音效果播放的代码,当一个人停下来然后再播放之后我怎么玩

1 个答案:

答案 0 :(得分:9)

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];

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