1

In my app when the screen is touched I want to play my file "pewpew.mp3". It is not working. I've looked at several of these posts but none of the are working. This is my code:

let shootNoise = SKAudioNode(fileNamed: "pewpew.mp3")
        shootNoise.autoplayLooped = false
        addChild(shootNoise)
        shootNoise.run(SKAction.play())
        hero.run(playNoise)

That is all inside of the

override func(touchesEnded)

Any ideas? I feel like I'm over-thinking this.

J. Derbs
  • 127
  • 1
  • 3
  • 10

1 Answers1

0

I'm late to answering this - but the code should/does work... so a couple of quick checks - is the file name and extension correct? Is the code block being run (ie, are touches ended being detected correctly). Are there other things in the scene that have changed the way sounds would be played? if you run this code in your app in a blank scene - does it work? (would have written a comment but am not allowed).

Wide Awake
  • 1,339
  • 1
  • 11
  • 18