Sound effect always is very important part of Game, I used to use other library that playing sound effect on iPhone App, but it totally make the size of the game bigger and slower. Now, I have move my game design from Cocoa To Cocos2d and it's include a few audio playing library. since I just need a background music and some sound effect, so I have choose SimpleAudioEngine.
Steps for playing background music
1. add your sound effect file to project (e.g. BG.mp3)
2. add header file to AppDelegate
#import "SimpleAudioEngine.h"
3. make sure you have add "SimpleAudioEngine.h" and "SimpleAudioEngine.m" from cocos2d
because I want to play the backgrund music after the app have finish loading. so I have make following change for applicationDidFinishLaunching
- (void) applicationDidFinishLaunching:(UIApplication*)application
{
[[SimpleAudioEngine sharedEngine] playBackgroundMusic:@"BG.mp3"];
window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
...
}
and Now, if we want to play a sound effect when user tap the button, we should preload the sound effect file on app delegate first, or any function before you play it.
- (void) applicationDidFinishLaunching:(UIApplication*)application
{
[[SimpleAudioEngine sharedEngine] playBackgroundMusic:@"BG.mp3"];
[[SimpleAudioEngine sharedEngine] preloadEffect:@"tapBtn.mp3"];\
window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
...
}
and play it when you need it
-(void)tapButton:(id)sender
{
[audioEngine playEffect:@"tapBtn.mp3"];
}
2 意見:
來看看你逛逛blog囉,加油! ........................................
色情性愛片破解色情守門人成人色情電影院線上免費色情短片色情動畫影線上免費性愛小說甜心寶貝貼影區都都成人貼圖站都都成人網都都貼片區都都貼圖站都督成人貼圖都督情色網野求拳陰莖套陰道貼圖陰道遊戲最女優最性感美女遊戲最新av女優無碼都都成人貼片都都成人區都都成人往聊一夜情聊天,ut聊天男 聊天室聊天室男同志莉的遊戲處女免費小弟弟影片交流區 小弟弟影片區 貼圖區色情小遊戲
張貼留言