【发布时间】:2015-02-05 03:42:46
【问题描述】:
我有这个功能,我在第一个场景中就实现了:
func ThemeSound() {
if let path = NSBundle.mainBundle().pathForResource("InfinityThemeMain", ofType: "wav") {
let enemy1sound = NSURL(fileURLWithPath:path)
println(enemy1sound)
var error:NSError?
ThemePlayer = AVAudioPlayer(contentsOfURL: enemy1sound, error: &error)
ThemePlayer.prepareToPlay()
ThemePlayer.play()
}
}
但问题是,它只播放一次主题。我需要它重复播放。我以为我知道如何做到这一点。
runAction(SKAction.repeatActionForever(SKAction.sequence([SKAction.runBlock(ThemePlayer), SKAction.waitForDuration(2.55)]))
但是我不能粘贴到 ViewController 中,因为 runAction 需要一个孩子来附加它。 还有什么办法可以吗?
【问题讨论】:
标签: ios swift sprite-kit