使按钮播放声音没有延迟 [英] make a button play sound without lag
本文介绍了使按钮播放声音没有延迟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在制作按钮播放声音,例如果冻车 3 中的按钮音效,当您像按下新游戏按钮一样按下时,它会产生类似于boop"的音效.我已经这样做了,但 ios 模拟器上存在大量延迟,这意味着 iphone HELP TKS 上会有更多!
Im making a button play sound, like a button sound effect for example in jely car 3 when you press like a new game button it would have a sound effect like "boop." I have done that but there is heaps of lag on the ios simulator which means there will be more on the iphone HELP TKS!
推荐答案
Inside ViewDidLoad
Inside ViewDidLoad
AVAudioPlayer *pp1 = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"bomb" ofType:@"wav"]] error:nil];
self.playerBG = pp1;
[pp1 prepareToPlay];
[pp1 release];
使用下面的代码在你想要的地方播放声音
use the below code to play sound where you want
[playerBG play];
这篇关于使按钮播放声音没有延迟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文