2011-01-19 121 views

回答

1

使用CocosDenshion。但是,您可能希望將音頻文件轉換爲AAC編碼的* .caf格式,因爲這是首選格式。

#import "SimpleAudioEngine.h" 

//preloading is important. do it in the scene init function 
[[SimpleAudioEngine sharedEngine] preloadBackgroundMusic:@"MyBgMusic.caf"]; 
[[SimpleAudioEngine sharedEngine] preloadEffect:@"MyEffect.caf"]; 

//later on 
[[SimpleAudioEngine sharedEngine] playBackgroundMusic:@"MyBgMusic.caf"]; 
[[SimpleAudioEngine sharedEngine] playEffect:@"MyEffect.caf"]; 

完整文檔是在這裏:http://www.cocos2d-iphone.org/api-ref/0.99.5/interface_simple_audio_engine.html