The sound plays everytime I tap the screen but there is a slight hiccup in the game where you could see it lag the screen. How would I fix this?
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()
}
}
lower the quality/bitrate of the audio that you play.