第一次使用 SpriteKit 播放声音时的小延迟 [英] Small delay when playing a sound for the first time with SpriteKit
本文介绍了第一次使用 SpriteKit 播放声音时的小延迟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我使用 [self 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.
拥有 iVar
SKAction *_ballsHitSound;
加载场景时设置
_ballsHitSound = [SKAction playSoundFileNamed:@"ballsCollide.mp3" waitForCompletion:NO];
然后声音就准备好了
[self runAction:_ballsHitSound];
这篇关于第一次使用 SpriteKit 播放声音时的小延迟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文