2013-03-01 52 views
0

(继续我想说我开发的在VMWare下的Mac OSX,所以如果有人知道它可能是一个VM问题之前,请回答关于反正那)EXC_BAD_ACCESS有声音在cocos2d

我下面的cocos2d的一个简单的教程,我赶到的声音

这是我使用音频

进口代码:

// Import the interfaces 
#import "HelloWorldLayer.h" 
#import "SimpleAudioEngine.h" 

// Needed to obtain the Navigation Controller 
#import "AppDelegate.h" 

Init方法:

-(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) 

我怎样才能使它发挥作用?

+1

您是否在实际设备上或仅在模拟器上试过这个?你可以毫无问题地演奏其他声音吗? – dqhendricks 2013-03-01 21:07:41

+0

在两者上我都遇到同样的问题。我不知道我错在哪里,因为在教程中,我看到这个人也是这样做的。 – user1714647 2013-03-01 21:30:52

+0

你有没有尝试过不同的MP3(最好是一个确认可以工作,即从另一个游戏的应用程序包)? – LearnCocos2D 2013-03-01 22:23:13

回答

0

经过一番小小的挖掘,我看到了其他人也有这个问题。他们的问题是他们的系统中没有安装音频驱动程序,因此根本没有声音播放,他们也收到了与您相同的错误。

http://www.cocos2d-iphone.org/forum/topic/13970

将是奇怪,如果这也是一个实际设备上发生的,虽然。你在PC上测试什么设备?

+0

问题可能会出现,我也安装了VMWare工具,但音频驱动程序未安装似乎很奇怪。我会做一些尝试并回复你。如果您了解其他可能的信息,请尽快回复。 – user1714647 2013-03-02 12:31:14

+0

无论如何,我也尝试与iPhone 4s – user1714647 2013-03-02 22:46:30