Game Development Reference
In-Depth Information
Listing 12-6. RootViewController.m (endOfGameCleanup)
-(void)endOfGameCleanup{
isPlaying = NO;
[self notifyGameCenter];
[self notifyFacebook];
}
In Listing 12-6, we see the task endOfGameCleanup that is called when the game ends, either by the
user's losing all her ship's health or by quitting her active game from the pause dialog. In this task,
we record that we are no longer playing by setting isPlaying to NO . The tasks notifyGameCenter and
notifyFacebook inform those two services of the user's score, and are described in Chapter 9.
BeltCommanderController , along with the Actor subclasses, creates the game.
will then explore the class BeltCommanderController and understand how it manages the game. Lastly,
we will look at each actor and understand how its implementation makes it work the way that it does.
Game Classes
In previous chapters, we have built a collection of classes for implementing a game. We have the
class GameController that is responsible for adding and removing actors from the game, as well
as rendering them into the screen. We also have the class Actor that represents the characters and
interactive elements of the game. Subclasses of Actor specify a Representation, a collection of
Behaviors, and some custom code. The following is a review of these classes.
The class GameController is the beating heart of the game; subclasses of this class need only add
Actors and animations will start happening. To customize the GameController , subclasses should
implement the task applyGameLogic to perform any game-specific logic, such as add or remove
Actors , check for victory or failure conditions, or anything else unique to a particular game.
In addition to updating the Actors and game logic, GameController is responsible for rendering
the Actors to the screen. GameController does this in two ways. First, GameController extends
UIControllerView so it has a primary UIView called view , which can be part of an applications scene.
Second, GameController has a UIView called actorsView , which is the super-view for all of the UIViews
that represent actors in the game. By specifying the view and actorsView in a XIB file, an instance
of GameController can draw to the screen. The second way that GameController is responsible for
rendering the game is by working with the Representation of each Actor to create a UIView to add as
 
Search WWH ::




Custom Search