How can play an .aac
开发者_运维百科 file in Cocos2d?
Use CocosDenshion. However, you may want to convert your audio files to AAC encoded *.caf format, as that is the preferred format.
#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"];
Full documentation is here: http://www.cocos2d-iphone.org/api-ref/0.99.5/interface_simple_audio_engine.html
Take a look at following book; you will get idea.
Adding Audio
精彩评论