Ios +;(id)替换场景后未调用场景
我有一个菜单项,点击时会调用goToGameLayer。goToGameLayer方法仅执行以下操作:Ios +;(id)替换场景后未调用场景,ios,objective-c,cocos2d-iphone,kobold2d,Ios,Objective C,Cocos2d Iphone,Kobold2d,我有一个菜单项,点击时会调用goToGameLayer。goToGameLayer方法仅执行以下操作: [[CCDirector sharedDirector] replaceScene:(CCScene*)[[GameLayer alloc] init]]; 但是,在replaceSecene之后,不会调用GameLayer中的+(id)scene方法 +(id)scene{ NSLog(@"+(id)scene CALLED"); CCScene *scene = [CC
[[CCDirector sharedDirector] replaceScene:(CCScene*)[[GameLayer alloc] init]];
但是,在replaceSecene之后,不会调用GameLayer中的+(id)scene方法
+(id)scene{
NSLog(@"+(id)scene CALLED");
CCScene *scene = [CCScene node];
GameLayer *layer = [GameLayer node];
[scene addChild: layer];
return scene;
}
我发现menuLayer中的dealloc方法是在GameLayer中的init方法之后调用的,但我不确定这是否会中断当前场景的处理
谢谢你的建议 未调用
场景
方法,因为您使用以下方法初始化对象:
[[GameLayer alloc] init]];
如果你使用
[GameLayer scene];
相反,将调用该方法,您也可以省略对CCScene
的强制转换:
[[CCDirector sharedDirector] replaceScene:[GameLayer scene]];
你到底在哪里调用
scene
?[[CCDirector sharedDirector]replaceSecene:[GameLayer scene]];