在Sprite Kit中播放声音

use*_*273 7 objective-c ios sprite-kit

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

#import <AVFoundation/AVFoundation.h>
Run Code Online (Sandbox Code Playgroud)

而这个代码在touchBegin方法中:

[self runAction:[SKAction playSoundFileNamed:@"fire.m4a" waitForCompletion:NO]];
Run Code Online (Sandbox Code Playgroud)

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

Terminating app due to uncaught exception 'Missing Resource', reason: 'Resource fire.m4a cannont be found in the main bundle'
Run Code Online (Sandbox Code Playgroud)

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

Gre*_*reg 11

从项目中删除该文件并再次添加.记得选择

Copy items into destination group...
Run Code Online (Sandbox Code Playgroud)

并选择您的项目作为目标(而不是测试).