这是我尝试的第一个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