【问题标题】:EXC_BAD_ACCESS with Sounds in Cocos2dCocos2d 中带有声音的 EXC_BAD_ACCESS
【发布时间】:2013-03-01 20:39:49
【问题描述】:

(在继续之前,我想说我是在 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) 

我怎样才能让它工作?

【问题讨论】:

  • 您是在实际设备上尝试过,还是只在模拟器上尝试过?你可以毫无问题地播放其他声音吗?
  • 在两者上,我都遇到了同样的问题。我不知道我哪里出错了,因为在教程中我看到这个人也是这样做的......
  • 您是否尝试过其他 MP3(最好是已确认可以使用的 MP3,即来自另一个游戏的应用程序包)?
  • 是的,我也尝试过使用 .mp3 和 .wav,但它还是会崩溃。我不知道为什么

标签: ios objective-c cocos2d-iphone


【解决方案1】:

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

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

如果这也发生在实际设备上会很奇怪。除了您的 PC,您还在什么设备上进行测试?

【讨论】:

  • 问题可能是thid,我也安装了VMWare Tools,但没有安装音频驱动程序似乎很奇怪。我会尝试并给你发短信。如果您知道有关此问题的其他可能信息,请尽快给我发短信。
猜你喜欢
  • 1970-01-01
  • 2012-06-30
  • 1970-01-01
  • 2011-09-28
  • 2011-08-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-02-16
相关资源
最近更新 更多