I'm trying to port over my code from 8.xx to 9.91 and am having an issue.
My code is as follows:
@implementation MainMenu
- (id) init {
self = [super init];
if (self != nil) {
CCSprite *back = [CCSprite spriteWithFile:@"tiltshift.png"];
back.anchorPoint = CGPointZero;
[self addChild:back z:-5];
//[self addChild:[MenuLayer node] z:0];
}
return self;
}
@end
@implementation MenuLayer
- (id) init {
self = [super init];
if (self != nil) {
CCMenuItemImage *next = [CCMenuItemImage itemFromNormalImage:@"Icon.png"
selectedImage:@"Icon.png" target:self selector:@selector(nextCallback:)];
CCMenu *menu = [CCMenu menuWithItems:next, nil];
[self addChild: menu z:1];
next.position = ccp(115,300);
[menu alignItemsHorizontally];
[self addChild:menu];
}
return self;
}
-(void)nextCallback: (id)sender {
OneScene * one = [OneScene node];
//[[Director sharedDirector] replaceScene:introne];
[[CCDirector sharedDirector] replaceScene:
[CCMoveInRTransition transitionWithDuration:0.5 scene:one]];
}
- (void) dealloc
{
[MainMenu release];
[super dealloc];
}
@end
When I add [self addChild:[MenuLayer node] z:0]; to the @implementation MainMenu the app crashes.
Without this the menu doesn't show up. It works perfectly on the 8.xx version.
Demetrius