为什么每次在 swift 中播放我的声音时我的游戏都会出现延迟?

Why is there a lag in my game everytime my sound is being played in swift?

每次我点击屏幕时都会播放声音,但游戏中会出现轻微的问题,您可以看到它滞后于屏幕。我将如何解决这个问题?

class level1: SKScene, SKPhysicsContactDelegate, GKGameCenterControllerDelegate {

    var jumpSound = NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource("tapsound", ofType: "wav")!)

    var jumpAudioPlayer = AVAudioPlayer()


    override func didMoveToView(view: SKView) {

    jumpAudioPlayer = AVAudioPlayer(contentsOfURL: jumpSound, error: nil)
    jumpAudioPlayer.prepareToPlay()



    }



    override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {

    theHero.physicsBody?.applyImpulse(CGVector(dx: 0, dy: 200))
    jumpAudioPlayer.play()

    }


    }

降低您播放的音频的 quality/bitrate。