2014-12-23 16 views
0

나는 공이 장애물 위로 점프하는 간단한 게임을 가지고있다. 장애물 (점프시 또는 점프 전에 충돌 할 때)과 접촉 할 때 주 메뉴 화면 (GameScene.Swift)으로 전환하기 전에 소리를 내고 싶습니다. 반드시 didBeginContact를 탐지하지만 반드시 그런 것은 아닙니다 .EndContact 어떤 이유로 사운드 파일이 재생되지 않습니다. 내가 도대체 ​​뭘 잘못하고있는 겁니까?소리가 들리지 않는다 연락처

class PlayScene: SKScene, SKPhysicsContactDelegate{ 
    //...... 
    let losingSoundAction = SKAction.playSoundFileNamed("losing.wav", waitForCompletion: true) 
    //.... 

    func didBeginContact(contact: SKPhysicsContact) { 
     //play the losing sound 
     self.runAction(losingSoundAction) 

     contact.bodyA.categoryBitMask = ColliderType.Hero.rawValue 
     died() 
    } 

    func died(){ 
     //change back to main screen 
     if let scene = GameScene.unarchiveFromFile("GameScene") as? GameScene { 
     let skView = self.view as SKView! 
     scene.scaleMode = .AspectFill 
     scene.GameSceneInstance = self 
     scene.score = score 
     skView.presentScene(scene) 
     } 
    } 
} 
+1

않습니다 .BeginContact execute? 그렇지 않다면 클래스를 물리 위임자로 설정 했습니까? – LearnCocos2D

+0

예 didBeginCOntact는 장면이 주 GameScene으로 변경되기 때문에 실행됩니다. – newbiedev

답변

0

PlayScene.Swift 파일은 내가 didEndContact로 사망() 함수 호출을 이동()와 그 문제를 해결하는 것 같았다.

관련 문제