0
这里是我游戏的主菜单上的init方法:获取线程1:EXC_BAD_ACCESS的Cocos2D
-(id) init {
if((self=[super initWithColor:ccc4(255, 255, 255, 255)])) {
// Get the screen dimensions
int screenWidth = [[CCDirector sharedDirector] winSize].width;
int screenHeight = [[CCDirector sharedDirector] winSize].height;
// Add the logo
CCSprite* logo = [[CCSprite node] initWithFile:@"Ninjasplash2.png"];
[logo setPosition:ccp(screenWidth/2.0,screenHeight * 0.65f)];
[self addChild:logo];
// Add the buttons
CCMenuItemLabel *startButton =
[CCMenuItemFont itemWithString:@"Start" target:self selector:@selector(onStart:)];
startButton.color = ccBLACK;
CCMenuItemLabel *quitButton =
[CCMenuItemFont itemWithString:@"Quit" target:self selector:@selector(onQuit:)];
quitButton.color = ccBLACK;
CCMenuItemLabel *optionsButton =
[CCMenuItemFont itemWithString:@"Options" target:self selector:@selector(onOptions:)];
optionsButton.color = ccBLACK;
CCMenu *menu = [CCMenu menuWithItems:startButton, quitButton, optionsButton, nil];
[menu alignItemsVertically];
[menu setPosition:ccp(screenWidth/2, screenHeight*0.25f)];
[self addChild:menu];
// Get the music started, yeh mon
//[[SimpleAudioEngine sharedEngine] playBackgroundMusic:@"island.mp3" loop:true];
}
return self;
}
当试图添加的标志,我得到上述错误,我绝对没有想法如何解决它。它变得令人难以置信的令人沮丧。如果您需要我添加更多信息,请让我知道,我会很高兴。谢谢。另外,我读过它可能与内存管理和释放有关,但它甚至不会加载这个主屏幕,所以没有任何东西可以释放。
堆栈跟踪我相信:
#0 0x01956df5 in objc_release()
#1 0x01957c60 in (anonymous namespace)::AutoreleasePoolPage::pop(void*)()
#2 0x01c8aed8 in _CFAutoreleasePoolPop()
#3 0x002c4385 in CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long)()
#4 0x002c41af in CA::Display::TimerDisplayLink::callback(__CFRunLoopTimer*, void*)()
#5 0x01d2a966 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__()
#6 0x01d2a407 in __CFRunLoopDoTimer()
#7 0x01c8d7c0 in __CFRunLoopRun()
#8 0x01c8cdb4 in CFRunLoopRunSpecific()
#9 0x01c8cccb in CFRunLoopRunInMode()
#10 0x02a20879 in GSEventRunModal()
#11 0x02a2093e in GSEventRun()
#12 0x00845a9b in UIApplicationMain()
#13 0x000c6526 in main at /Users/MaristUser/Desktop/Ninja Run/Ninja Run/main.m:14
你得到一个堆栈跟踪? – 2013-03-06 01:55:02
我使用堆栈跟踪编辑了文章 – Testyrabbit 2013-03-06 02:34:32
访问错误通常比尝试引用数组中的某个对象更常见:1)数组不存在或2)该数组中的对象为空/不存在。上面没有任何东西立刻跳出来。你确定这里发生错误吗?你是否已经完成了调试器? – Clev3r 2013-03-07 04:11:38