Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Play sound in Sprite Kit

I have the following code in myScene.h :

#import <AVFoundation/AVFoundation.h>

And this code in the touchBegin method:

[self runAction:[SKAction playSoundFileNamed:@"fire.m4a" waitForCompletion:NO]];

The audio file is in the main folder. When I run the app and touch the app is shut down and I get the following error:

Terminating app due to uncaught exception 'Missing Resource', reason: 'Resource fire.m4a cannont be found in the main bundle'

I thought this is the way to play audio in Sprite Kit but I must be doing something wrong..

like image 693
user2255273 Avatar asked Feb 13 '14 14:02

user2255273


1 Answers

Delete the file from your project and add it again. Remember to select

Copy items into destination group...

And select your project as a target (not test).

like image 133
Greg Avatar answered Sep 19 '22 20:09

Greg