장면 컨트롤러 (상태 관리자) 클래스로 장면을 전환하는 간단한 응용 프로그램을 만드는 연습을하고 있습니다. Dealloc에서 경고합니다.
나는 내 장면 생성 :+(CCScene *) scene
{
CCScene *scene = [CCScene node];
GameMenu *layer = [GameMenu node];
[scene addChild: layer];
return scene;
}
-(id)init{
if ((self = [super init])){
self.isTouchEnabled = YES;
CGSize winSize = [[CCDirector sharedDirector] winSize];
gameMenuLabel = [CCLabelTTF labelWithString:@"This is the Main Menu. Click to Continue" fontName:@"Arial" fontSize:13];
gameMenuLabel.position = ccp(winSize.width/2, winSize.height/1.5);
[self addChild:gameMenuLabel];
}
return self;
}
-(void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
NSLog(@"ccTouchesBegan: called from MainMenu object");
[[StateManager sharedStateManager] runSceneWithID:kGamePlay];
}
-(void)dealloc{
[gameMenuLabel release];
gameMenuLabel = nil;
[super dealloc];
}
@end
을하지만이 경고 점점 계속 : https://dl.dropbox.com/u/1885149/Screen%20Shot%202012-10-06%20at%205.23.43%20PM.png (아마 많은 도움을하지만 난 스크린 샷을 링크 할 생각
나는 그것을 함께 할 수있는 뭔가가 생각합니다. 내 장면에서 dealloc을 주석 처리하면 경고 메시지가 표시되지 않습니다. 도움을 주시면 감사하겠습니다.
장면 전환을위한 내 Statemanager의 방법입니다.
-(void)runSceneWithID:(SceneTypes)sceneID {
SceneTypes oldScene = currentScene;
currentScene = sceneID;
id sceneToRun = nil;
switch (sceneID) {
case kSplashScene:
sceneToRun = [SplashScene node];
break;
case kGameMenu:
sceneToRun = [GameMenu node];
break;
case kGamePlay:
sceneToRun = [GamePlay node];
break;
case kGameOver:
sceneToRun = [GameOver node];
break;
default:
CCLOG(@"Unknown ID, cannot switch scenes");
return;
break;
}
if (sceneToRun == nil) {
// Revert back, since no new scene was found
currentScene = oldScene;
return;
}
if ([[CCDirector sharedDirector] runningScene] == nil) {
[[CCDirector sharedDirector] runWithScene:sceneToRun];
} else {
[[CCDirector sharedDirector] replaceScene:sceneToRun];
}
}
게시물을 텍스트 형식으로 추가하여 검색 가능하도록해야합니다. –
스크린 샷의 코드는 질문의 코드와 완전히 다릅니다. – jrturton
스크린 샷에 "경고"가 아닌 중단 점이나 충돌이 표시됩니다. – newacct