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

前端 未结 3 1288
南旧
南旧 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 08:00

    To translate the Karl Voskuil preload sounds answer's in Swift 2.x :

    let preloadSound = SKAction.playSoundFileNamed("my-sound-effect.caf", waitForCompletion: false)
    

    so after you can do :

    playSound(preloadSound)
    
    ...
    
    func playSound(soundVariable : SKAction)
    {
        runAction(soundVariable)   
    }
    

提交回复
热议问题