Game Development Reference
In-Depth Information
IBOutlet HighscoreController *highscoreController;
CoinsGame* previousGame;
BOOL isPlayingGame;
}
-(void)setPreviousGame:(CoinsGame*)aCoinsGame;
-(CoinsGame*)currentGame;
- (IBAction)continueGameClicked:(id)sender;
- (IBAction)newGameClicked:(id)sender;
- (IBAction)highScoresClicked:(id)sender;
- (IBAction)aboutClicked:(id)sender;
- (IBAction)aboutDoneClicked:(id)sender;
- (IBAction)highscoreDoneClicked:(id)sender;
-(void)loadImages;
-(void)showPlayView: (UIInterfaceOrientation)interfaceOrientation;
@end
In Listing 3-1, we import three other classes defined in this project, including the default import
statement for UIKit. The rest of the IBOutlet statements are basic declarations, allowing a number
of different views to be accessed. The IBOutletCollection definitions represent a new type of
connection for us. An IBOutletCollection acts very much like an IBOutlet , except it allows you to
connect multiple items to a single NSArray . In our case, we have two labels for displaying the score:
landscape and portrait. Instead of having an IBOutlet (and variable) for each of these, we can simply
use an IBOutletCollection , so the NSArray scoreLabels will contain both of these labels at runtime.
When it is time to update the UI with a new score, we simply update the text of all of the UILabels
in the array scoreLabels . We follow the same pattern for the labels that display the remaining turns,
where each is stored in the NSArray remainingTurnsLabels .
Bringing the Views onto the Screen
That completes our overview of how the different views are defined. Now let's take a look at how
each of these views is brought onto the screen, starting with the Loading view.
We know that the Main view for the class GameController is displayed when the application loads,
just as it did in Chapter 2. However, the Main view for GameController is empty—it is effectively the
root component for our application. When we change views in the application, we will be adding and
removing views from this root view. Listing 3-2 shows the viewDidLoad task from GameController ,
where we add the first view we want the user to see.
Listing 3-2. GameController.m (viewDidLoad)
- (void)viewDidLoad
{ [super viewDidLoad];
[self.view addSubview:loadingView];
[self performSelectorInBackground:@selector(loadImages) withObject:nil];
}
 
Search WWH ::




Custom Search