播放声音时,延时小,第一次与SpriteKit [英] Small delay when playing a sound for the first time with SpriteKit

查看:221
本文介绍了播放声音时,延时小,第一次与SpriteKit的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用[自playSoundFileNamed]播放声音,有一个小的延迟在第一时间发出声音,其中整个应用程序冻结大约半秒,但在这之后它的罚款。我怎样才能摆脱呢?

When I play a sound using [self playSoundFileNamed], there is a small delay the first time a sound is played where the whole app freezes for about half of a second, but after that it's fine. How can I get rid of this?

推荐答案

在我的游戏设置方法,我做这样的事情,它似乎运作良好。

In my game setup method, I do something like this and it seems to work well.

有一个伊娃

 SKAction *_ballsHitSound;

设置它负载时的情景

Set it up when load the scene

_ballsHitSound = [SKAction playSoundFileNamed:@"ballsCollide.mp3" waitForCompletion:NO];

然后声音是准备去

then the sound is ready to go

[self runAction:_ballsHitSound];

这篇关于播放声音时,延时小,第一次与SpriteKit的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆