(在继续之前,我想说我在 VMWare 下的 Mac OSX 上开发,所以如果有人知道这是否可能是 VM 问题,请无论如何回答)
我正在学习 cocos2d 的一个简单教程,然后我就听到了声音
这是我用于音频的代码
进口:
// Import the interfaces
#import "HelloWorldLayer.h"
#import "SimpleAudioEngine.h"
// Needed to obtain the Navigation Controller
#import "AppDelegate.h"
初始化方法:
-(id) init
{
// always call "super" init
// Apple recommends to re-assign "self" with the "super's" return value
if( (self=[super init]) )
{
[[SimpleAudioEngine sharedEngine] playBackgroundMusic:@"Field1.mp3" loop:YES];
CCMenuItemImage *uno = [CCMenuItemImage itemWithNormalImage:@"vblue.png" selectedImage:@"vblue.png" target:self selector:@selector(uno)];
uno.position = ccp(-150,0);
CCMenuItemImage *due = [CCMenuItemImage itemWithNormalImage:@"vgreen.png" selectedImage:@"vgreen.png" target:self selector:@selector(uno)];
due.position = ccp(-50,0);
CCMenuItemImage *start = [CCMenuItemImage itemWithNormalImage:@"play.png" selectedImage:@"play.png" target:self selector:@selector(uno)];
start.position = ccp(150,0);
CCMenuItemImage *stop = [CCMenuItemImage itemWithNormalImage:@"pausa.png" selectedImage:@"pausa.png" target:self selector:@selector(uno)];
stop.position = ccp(50,0);
CCMenu *menu = [CCMenu menuWithItems:uno,due,start,stop, nil];
[self addChild:menu];
}
return self;
}
有问题的行是
[[SimpleAudioEngine sharedEngine] playBackgroundMusic:@"Field1.mp3" loop:YES];
由于 Xcode 报告了音频错误并且没有该行,所以游戏可以正常工作。
编译器输出:
<AudioControl> Error '!obj' trying to fetch default input device's sample rate
2013-03-01 12:29:09.101 Tutorial10[374:4803]
<AudioControl> Error getting audio input device sample rate: '!obj'2013-03-01 12:29:09.102 Tutorial10[374:4803]
<AudioControl> AQMEIOManager::FindIOUnit: error 'NoHW'
2013-03-01 12:29:09.104 Tutorial10[374:1b03]
<0xb0115000> AQMEIOManager::FindIOUnit: error 'NoHW'
(lldb)
我怎样才能让它工作?