在Sprite Kit中播放声音

时间:2014-02-13 14:52:23

标签: ios objective-c sprite-kit

我在myScene.h中有以下代码:

#import <AVFoundation/AVFoundation.h>

这个代码在touchBegin方法中:

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

音频文件位于主文件夹中。当我运行应用程序并触摸应用程序关闭时,我收到以下错误:

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

我认为这是在Sprite Kit中播放音频的方法,但我一定是做错了..

1 个答案:

答案 0 :(得分:11)

从项目中删除该文件并重新添加。 请记住选择

Copy items into destination group...

选择您的项目作为目标(而非测试)。