2
在SpriteKit(对于那些不熟悉它的人),有一种方法来加载和卸载场景,以及它们之间的过渡(视觉)。场景过渡的声音,没有口吃
我试图在场景之间进行合理的播放,因为它们过渡......没有口吃。
到目前为止,我已经试过可以创建没有声音或声音断断续续,甚至使用声音管理器,像这样的所有方式:
import AVFoundation
import SpriteKit
open class SoundManager {
static let soundStart = SKAction.playSoundFileNamed("ActionBeep_AP1.7", waitForCompletion: true)
static var coinSound = NSURL(fileURLWithPath:Bundle.main.path(forResource: "ActionBeep_AP1.7", ofType: "wav")!)
static var audioPlayer = AVAudioPlayer()
open static func playCoinSound(){
guard let soundToPlay = try? AVAudioPlayer(contentsOf: coinSound as URL) else {
fatalError("Failed to initialize the audio player with asset: \(coinSound)")
}
soundToPlay.prepareToPlay()
self.audioPlayer = soundToPlay
self.audioPlayer.play()
}
}
人有任何的成功使场景转换声音流畅运行?我意识到在场景转换过程中会发生很多事情,这可能不会帮助声音引擎。但是认为在场景转换过程中必须有一种清晰的声音播放方式。
是的,我已经尝试过.caf和.mp3和.wav文件,所有这些文件都有不同的“压缩”和原始状态。我认为这就是我如何播放这些问题的声音,而不是文件类型。
你是否正在过渡之前调用它?尝试在应用启动时预加载歌曲,而不是在尝试播放之前。像这样的东西http://stackoverflow.com/questions/40296793/cannot-stop-background-music-from-within-game-scenes-swift-3-spritekit/40361443#40361443 – crashoverride777