這是我嘗試的第一個cocos2d應用程序,我從書中學習Cocos2d的例子,但它似乎指的是較早版本的cocos。添加一個場景導演cocos2d iOS
我創建了一個場景,並在其init方法中添加了2個圖層。
現在教程說,在我的delegate.m我要加入這一行(準確地說改變以前一個strted的HelloWorldScene):
[director_ runWithScene:[GameScene node]];
但我得到一個錯誤。
奇怪的是,它並沒有使用該代碼在所有,但一個:
[director_ pushScene: [IntroLayer Scene]];
但是,如果我用這個,我也得到一個錯誤:
[director_ pushScene: [GameScene node]];
我GameScene是在這裏:
#import "GameScene.h"
@implementation GameScene
-(id) init{
self=[super init];
if (self!=nil){
BackgroundLayer *backgroundLayer=[BackgroundLayer node];
[self addChild:backgroundLayer z:0];
GameplayLayer *gameplayLayer=[GameplayLayer node];
[self addChild:gameplayLayer z:5];
}
}
@end
和錯誤,我得到:
EXC_BAD_ACCESS in both cases.
如何從我的appdelegate啓動這個場景?
你使用的是哪個版本的cocos2d和xcode? – MrWaqasAhmed
在Xcode中添加一個異常斷點。 http://stackoverflow.com/questions/4961770/run-stop-on-objective-c-exception-in-xcode-4然後你可以告訴我們更多關於錯誤的信息。 EXC_BAD_ACCESS是一個通用錯誤。 – LearnCocos2D