当我的英雄节点与Swift Spritekit中的硬币接触时,我的游戏会在声音播放时滞后?

时间:2015-04-08 17:04:02

标签: swift avaudioplayer

当我的英雄节点收集硬币时,当我的游戏播放时有一点障碍。为什么会这样?这是我的代码:

class GameScene: SKScene, SKPhysicsContactDelegate,    
GKGameCenterControllerDelegate {    

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

var popAudioPlayer = AVAudioPlayer()


override func didMoveToView(view: SKView) {

popAudioPlayer = AVAudioPlayer(contentsOfURL: popSound, error: nil)

 }


   if firstBody.categoryBitMask == HeroCategory && 
   secondBody.categoryBitMask == CoinCategory {
        coinAudioPlayer.play()
        coinAudioPlayer.currentTime = NSTimeInterval(1.0)
        coinAudioPlayer.prepareToPlay()
     }

0 个答案:

没有答案