每当我的声音快速播放时,为什么我的游戏会出现延迟?

时间:2015-06-15 02:46:27

标签: ios swift avaudioplayer

每次点击屏幕时都会播放声音,但游戏中有轻微的打嗝,你可以看到它落后于屏幕。我该如何解决这个问题?

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()

    }


    }

1 个答案:

答案 0 :(得分:0)

降低播放音频的质量/比特率。