2012-01-23 52 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]; 

這樣可以解決你的問題,但唯一的缺點是你必須自己插入延遲時間。希望它適合你的情況。