2016-12-20 10 views
0

단추를 눌렀을 때 소리를 추가하려고했지만 소리가 나지 않으면 단추를 누르십시오. 터미널에 실수가 없습니다.오류없이 소리가 나지 않습니다

이미 다른 컴퓨터에서 컴파일을 시도하고 iPhone에서 디버깅을 시도했습니다. 소리가 들리지 않습니다.

이 문제를 해결할 수 있도록 도와주세요.

class MenuScene : SKScene { 
    let txtAtlas : SKTextureAtlas = SKTextureAtlas(named: "UI.atlas") 
    let txtAtlas2 : SKTextureAtlas = SKTextureAtlas(named: "mapbc.atlas") 
    let startBut = SKSpriteNode() 
    let tssound = SKAction.playSoundFileNamed("tssound.wav", waitForCompletion: false) 

    override func didMove(to view: SKView) { 
     self.anchorPoint = CGPoint(x: 0.5, y: 0.5) 
     self.backgroundColor = UIColor.black 

     let logo = SKLabelNode(fontNamed: "Helvetica") 
     logo.text = "Train Control" 
     logo.position = CGPoint(x: 0, y: 100) 
     logo.fontSize = 60 
     logo.fontColor = UIColor.green 
     self.addChild(logo) 

     startBut.texture = txtAtlas.textureNamed("stbut.png") 
     startBut.size = CGSize(width: 230, height: 85) 
     startBut.position = CGPoint(x: 0, y: -20) 
     startBut.name = "StartBtn" 
     self.addChild(startBut) 

     let startText = SKLabelNode(fontNamed: "AvenirNext-HeavyItalic") 
     startText.text = "Start Manage!" 
     startText.verticalAlignmentMode = .center 
     startText.position = CGPoint(x: 0, y: 2) 
     startText.fontSize = 30 
     startText.name = "StartBtn" 
     startBut.addChild(startText) 

     let bcmap = SKSpriteNode() 
     bcmap.texture = txtAtlas2.textureNamed("mapbc.png") 
     bcmap.zPosition = -1 
     bcmap.size = CGSize(width: 400.0, height: 350.0) 
     bcmap.position = CGPoint(x: -100, y: 0) 
     bcmap.alpha = 0.7 
     self.addChild(bcmap) 

     let stbutaction = SKAction.sequence([SKAction.fadeAlpha(to: 0.7, duration: 0.9), 
              SKAction.fadeAlpha(to: 1.0, duration: 0.9)]) 
     startBut.run(SKAction.repeatForever(stbutaction)) 
    } 

    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) { 
     for touch in (touches) { 
      let location = touch.location(in: self) 
      let nodeTouched = atPoint(location) 

      if nodeTouched.name == "StartBtn" { 
       // Player touched the start text or button node 
       self.view?.presentScene(GameScene(size: self.size)) 
       self.run(tssound) 
      } 
     } 
    } 
} 

답변

0

GameScene 등의 사운드를 초기화하고 실행해야합니다. 장면이로드 될 때. GameScene

으로 전환 한 후에 존재하지 않는 MenuScene에서 사운드를 실행하려고합니다.
관련 문제