下载地址:http://download.csdn.net/detail/daiyelang/6628605
使用:下载后导入项目中
一、CCMenu
游戏中的菜单必不可少,CCMenu正是你想要的。
要创建CCMenu,你必须有CCMenuItem对象,CCMenuItem便是你菜单中的某个选项,可以为图片、文字等
cocos2d为menu item提供了必要的转换方法,比如CCMenuItemLabel你可以通过CCLabelBMFont得到;游戏中某些开关,比如声音开关可以用CCMenuItemToggle对象
每一个CCMenuItem都可以在创建的时候绑定某个对象的方法,当这个CCMenuItem被点击的时候会触发这个方法
二、CocosDenshion
cocos2d中集成了CocosDenshion,不过游戏中我们一般都是整个背景音乐或者来点音效,所以我们只需要用SimpleAudioEngine就可以了。
SimpleAudioEngine其实是对CDAudioManager进行了一些封装,我们暂时不去关注细节实现,先看看怎么使用
这是一段通用的代码,用来确保建立SimpleAudioEngine对象成功
当对象成功创建以后,便可以使用这个对象了,预加载的过程会hang住程序,所以不要在主线程中进行声音的预加载
[soundEnginepreloadBackgroundMusic:trackFileName];
[soundEngineplayBackgroundMusic:trackFileNameloop:YES];
kAMM_FxOnly,//!Other apps will be able to play audio
kAMM_FxPlusMusic,//!Only this app will play audio
kAMM_FxPlusMusicIfNoOtherAudio,//!If another app is playing audio at start up then allow it to continue and don't play music
kAMM_MediaPlayback,//!This app takes over audio e.g music player app
kAMM_PlayAndRecord//!App takes over audio and has input and output
都很好懂,就不一一翻译了