I'm trying to implement the "3d" audio Apple has added to SpriteKit, but the sounds really don't seem to be positioned at all, even with headphones on. Here's my relevant code.
Play Sound function:
func playTapSound(node: SKNode) {
let tapSound = SKAudioNode(fileNamed: "glassNote")
tapSound.positional = true
tapSound.autoplayLooped = false
node.addChild(tapSound)
tapSound.runAction(SKAction.play())
}
Game Scene:
let listenerNode = SKNode()
...
override func didMoveToView(view: SKView) {
listenerNode.position = view.center
listener = listenerNode
}
playTapSound
gets called if the user taps a game piece node.
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
let touchedNode = scene.nodeAtPoint(sceneTouchPoint)
playTapSound(touchedNode)
}
I've checked the positions of all the nodes including the listener node and they're all correct. Listener node is in the center of the screen and the game pieces are basically a checkerboard layout.
When I tap a piece, I really can't tell there's any sort of positioning on the audio. Is it just extremely subtle? Can't find much info out there about it except Apple saying it's part of SpriteKit..
SKAudioNode
. The difference between the audio node being on the left and on the right of thelistener
was very obvious. – 0x141E