showing menu view the same as in applicationDidFinishLaunching
I have a piece of code in MyClassAppDelegate:
[[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO];
application.idleTimerDisabled = YES;
[window setBackgroundColor:[UIColor blackColor]];
appButton1 = [UIButton buttonWithType:0];
[appButton1 setImage:[UIImage imageNamed:@"a.png"] forState:UIControlStateNormal];
[appButton1 addTarget:self action:@selector(startGame) forControlEvents:UIControlEventTouchUpInside];
[window addSubview:appButton1];
[window makeKeyAndVisible];
-(void)startGame {
[appButton1 removeFromSupe开发者_运维知识库rview];
mGC = [[MainGameController alloc] initWithNibName:nil bundle:nil];;
[window addSubview:mGC.view];
[mGC.view setFrame:[[UIScreen mainScreen] applicationFrame]];
}
It will give the user an option to play one or more games after the app has launched (my code shows only one option, but I can add more buttons if more selections are required).
I would like to create a view at the end of the game which will have "play again" and "menu" buttons. If user selects menu button I want to show user same view as created inside applicationDidFinishLaunching. Do I have to remove all existing views and add menu view as done initially in applicationDidFinishLaunching? Essentially, after user selects "menu" option I would like to start with a clean slate same as inside applicationDidFinishLaunching.
You do not have to remove all Views, instead at the end the view you are going to create, user's activity will lead him back to mGC's view. But you do have to implement some game engine kind of work which will keep track of game status and do game initialization, game level-up,etc.
精彩评论