Sprite Kit game “hickup” when the first sound is played

前端 未结 3 1316
南旧
南旧 2021-01-18 07:23

In my sprite kit game I use a SKAction to play a mp3 file when two sprites did collide. While the game works fine I noticed a small \"hickup\" in the game the first time the

3条回答
  •  佛祖请我去吃肉
    2021-01-18 07:40

    I have a similar problem so here is what I found so far (I don't know if it fixes the problem because I can't try it right now).

    I think the problem is that you didn't preload the sound effect. So when it plays for the first time, it is loaded and then played. That is why your game freezes.

    The solution is to preload the effect when you initialize your scene. You can find an example in this tutorial (scroll down to the part named "Gratuitous Sound Effects"). It is pretty clear and well explained.

    Hope it helps.

提交回复
热议问题