it is my first cocos2d app I try, and I am following example from book Learning Cocos2d but it seems it refers to an older version of cocos.
I have created a scene, and in its init method I add 2 layers.
Now the tutorial says, that in my delegate.m I should add this line (to be precise change the previous one that strted the HelloWorldScene) :
[director_ runWithScene:[GameScene node]];
But I am getting an error.
The weird thing is that it does not use that code at all,but that one:
[director_ pushScene: [IntroLayer Scene]];
But if I use this, I also get an error:
[director_ pushScene: [GameScene node]];
My GameScene is here:
#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
and the errors I get:
EXC_BAD_ACCESS in both cases.
How can I start this scene from my appdelegate?
Thanks for your help!
I did use that:
[director_ pushScene: [GameScene node]];
but the actual problem is that in my GameScene init method I have forgotten to return self.