2012-01-23 55 views
1

如何在cocos2d按顺序播放的声音没有任何的身体有例如我有三个声音就像播放声音的序列在cocos2d

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

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

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

这是声音效果的代码打我怎么能玩的时候,任何想法一个是停止,然后再玩另一个游戏

+0

您可以将CCSequence用于声音的播放效果!这将是更好的方式! – Marine

回答

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

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