开发者

How to play .aac file in Cocos2d?

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜