AVAudioPlayer in Sprite Kit 'Failed to load resource' reason resource 'could not load sound.caf'

389 views Asked by At

I am trying to play a sound effect when the user presses a correct answer. Here is the code:

if ([node.name isEqualToString:correctAnswer]) {
    [self runAction:[SKAction playSoundFileNamed:@"correct.caf" waitForCompletion:NO]];
}

When I run the app and the I press the button, the app throws an exception:

*** Terminating app due to uncaught exception 'Failed to Load Resource', reason: 'Resource correct.caf can not be loaded'

There isn't much documentation for Sprite Kit yet, so I don't know whether or not this is the correct way to play a sound effect in Sprite Kit. I am following the Ray Wenderlich tutorial: http://www.raywenderlich.com/42699/spritekit-tutorial-for-beginners Are there any suggestions?

1

There are 1 answers

0
matt On

You are asking for something called "correct.caf" and there is no such thing in your app bundle. Create a CAF sound file called "correct.caf" and add it to your project. Or add some other sound file to your project and reference that.