想定义游戏声音? 应该跟随如下几步:
1.首先在文件中加入库函数.
#import <AudioToolbox/AudioToolbox.h>
2.应该把audioToolBox包加入到应用文件中. bulid phases.---
3.找到我们自定义的声音并定义为系统声音. 代码如下:
-(void)playWinSound {
NSString *path = [[NSBundle mainBundle] pathForResource:@"win"
ofType:@"wav"];
SystemSoundID soundID;
AudioServicesCreateSystemSoundID(
(__bridge CFURLRef)[NSURL fileURLWithPath:path], &soundID);
AudioServicesPlaySystemSound (soundID);
winLabel.text = @"WIN!";
[self performSelector:@selector(showButton) withObject:nil
afterDelay:1.5];
}
4.调用函数~~