Game Development Reference
In-Depth Information
[welcomeView removeFromSuperview];
UIInterfaceOrientation interfaceOrientation = [self interfaceOrientation];
[self showPlayView:interfaceOrientation];
[coinsController newGame];
[UIView commitAnimations];
isPlayingGame = YES;
}
- (IBAction)highScoresClicked:(id)sender {
[UIView beginAnimations:nil context:@"flipTransitionToBack"];
[UIView setAnimationDuration:1.2];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.view cache:YES];
[welcomeView removeFromSuperview];
[self.view addSubview:highscoreController.view];
[UIView commitAnimations];
}
- (IBAction)aboutClicked:(id)sender {
[UIView beginAnimations:nil context:@"flipTransitionToBack"];
[UIView setAnimationDuration:1.2];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.view cache:YES];
[welcomeView removeFromSuperview];
[self.view addSubview: aboutView];
[UIView commitAnimations];
}
Listing 3-4 displays all of the tasks used to control which view we show, chosen from the Welcome
view. The first three lines of each task sets up the animation that will be used to transition
from one view to another. The last line that calls
UIView
's
commitAnimations
task indicates that
we have specified all of the UI changes we want animated, and that the animation should be
shown to the user. The type of animation is controlled by setting the context string on
UIView
's
beginAnimations:context:
task. In order actually change which view will be displayed, we simply
have
welcomeView
remove itself from its parent by calling
removeFromSuperview
. Then we add the
desired
view
to
self.view
by calling the task
addSubview:
.
For the High Score view and the About view, we want the user to navigate back to the Welcome
view. Listing 3-5 shows these action tasks.