1

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

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

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

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

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

4

1 回答 1

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

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

于 2012-02-02T01:11:33.657 回答