2015-06-19 70 views
0

我正在用Sprit Kit構建遊戲,我在didMoveToView方法中使用了AVAudioPlayer的連續循環聲音。但是我還使用SystemSoundID使用了其他四種聲音,這些聲音是在didMoveToView方法之外創建的。問題是當我玩遊戲時,使用AVAudioPlayer播放聲音似乎淹沒了我使用systemSound的所有其他聲音。我可以使用AVAudio來處理所有聽起來不錯的聲音,但它也會讓我的遊戲減慢一點。只是想知道是否有替代或修復?忘了提及,它只是似乎是一個問題,當我插入耳機,但它播放時沒有工作正常。播放AVAudioPlayer和SystemSoundID

這裏是我的代碼:

- (void)didMoveToView:(SKView *)view 


NSURL *playSound = [NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:@"jungleSound" ofType:@"wav"]]; 

NSError *error; 

player = [[AVAudioPlayer alloc]initWithContentsOfURL:playSound error:&error]; 

[player play]; 

player.numberOfLoops = -1; //Continuous play// 

而且方法

NSString *soundPath = [[NSBundle mainBundle] pathForResource:@"Jump2" ofType:@"wav"]; 
SystemSoundID soundID; 
AudioServicesCreateSystemSoundID((__bridge CFURLRef)[NSURL fileURLWithPath: soundPath], &soundID); 
AudioServicesPlaySystemSound(soundID); 


NSString *soundPath2 = [[NSBundle mainBundle] pathForResource:@"squish" ofType:@"wav"]; 
SystemSoundID soundID2; 
AudioServicesCreateSystemSoundID((__bridge CFURLRef)[NSURL fileURLWithPath: soundPath2], &soundID2); 
AudioServicesPlaySystemSound(soundID2); 


NSString *soundPath3 = [[NSBundle mainBundle] pathForResource:@"Powerup3" ofType:@"wav"]; 
SystemSoundID soundID3; 
AudioServicesCreateSystemSoundID((__bridge CFURLRef)[NSURL fileURLWithPath: soundPath3], & soundID3); 
AudioServicesPlaySystemSound(soundID3); 

回答

0

打開音量調下設置的鈴聲和提醒之外解決了這個問題。