Panda Pig • Patty original or translated works. Welcome reprint, Reprint please indicate the source.
If you feel that the writing is not good please more advice, if you feel good please support a lot of praise. Thank you! Hopy;)
The Skaudionode code that works well before the new Xcode seems to have some minor problems, which happens after the scene transitions.
For example, game home View Gamescene creates a new instance of itself after new game and then transforms the past:
"GameScene") newScene!.scaleMode.AspectFill let reveal = SKTransition.flipHorizontalWithDuration(0.5) self.view?.presentScene(newScene!, transition: reveal)
Note that a sktransition instance is used to create the transition effect, with a transition time of 0.5 seconds. The test found that if you use Skaudionode to play a sound in the scene loading method, you can only play 0.5 seconds and then it will be silent. If the transition time changes, The Skaudionode playback time also changes. No matter what, just complete the transition and the sound disappears!
Beginning to think that the old scene needs to do the cleanup, so wrote the following method:
override func willMoveFromView(view: SKView) { iflet music = bgMusic{ true music.removeFromParent() bgMusic = nil } iflet music = bgMusicAlarm{ true music.removeFromParent() bgMusicAlarm = nil } }
But the problem remains.
Then the original scene loading method play sound to do a small delay operation, there is no problem, good magic!
runAction(SKAction.waitForDuration(0.01),completion:{ self.playBgMusic("SpaceGame.caf") })
The silent problem of Skaudionode in Xcode7.3.1 after scene conversion