(繼續我想說我開發的在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)
我怎樣才能使它發揮作用?
您是否在實際設備上或僅在模擬器上試過這個?你可以毫無問題地演奏其他聲音嗎? – dqhendricks 2013-03-01 21:07:41
在兩者上我都遇到同樣的問題。我不知道我錯在哪裏,因爲在教程中,我看到這個人也是這樣做的。 – user1714647 2013-03-01 21:30:52
你有沒有嘗試過不同的MP3(最好是一個確認可以工作,即從另一個遊戲的應用程序包)? – LearnCocos2D 2013-03-01 22:23:13