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