开发者

make a button play sound without lag

开发者 https://www.devze.com 2023-02-28 00:52 出处:网络
Im making a button play sound, like开发者_Python百科 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

Im making a button play sound, like开发者_Python百科 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

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];
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号