Game Development Reference
In-Depth Information
The SideBySideScoreElement helper class is used to display a text label and corresponding
dynamic text field as a pair side by side on the screen. For example, it can be implemented by the
ScoreBoard class to display the word Score followed by the user's current score.
The Game class
The Game class is a stub style class that all games in the framework will inherit from. It contains
the basic variables and functions needed to work with the GameFrameWork class.
The Custom event classes
The framework makes use of events to communicate between classes. The instances of the
Game class will use events to communicate with the ScoreBoard and the Main classes. We will
create a custom Main.as class for each game. This Main class will be a sub-class (or child) of the
GameFrameWork class. Some of the events we will use will be simple events. These are instances
of the standard Flash Event class used for basic communication. By this, we mean events that
don't need to send any data along with them. For example, instances of the Game.as framework
class will have a constant variable called GAME_OVER . This constant will be used as the name of a
simple Event instance that is fired off with the standard dispatchEvent function call. This example
GAME_OVER event wil be used to tell the Main.as to move to the game over
( STATE_SYSTEM_GAME_OVER ) state in the main state loop when the current game has completed.
We will also be creating three distinct custom event classes as part of the framework. These will
be used to send specific data from the Game class instance to the Main.as ( GameFrameWork.as
instance) class. The Main.as will act on the data sent and if needed, pass the data to other
framework classes. By doing this, we are using Main.as as a sort of message gateway.
The CustomEventButtonId.as class
This custom event will have the ability to pass an identification integer value to the listening
function. It is used for cases where multiple buttons share the same listener function. It will be
used in the framework (specifically in the GameFrameWork instance, Main.as ) to allow BasicScreen
instances to each share the same listener functions if they employ a SimpleBlitButton . You will
see this when we examine the GameFrameWork class file. It can also be used for any game or
application that needs to send a basic integer id along with an Event instance.
The CustomEventLevelScreenUpdate.as class
This custom event will be used by the Game.as class instance to send data to a BasicScreen
instance we will create called levelInScreen . The levelInScreen will have the ability to display
custom text between each level. The event listnener for this event will change this text with a
value passed when the event is fired off. The Main.as ( GameFrameWork.as sub-class) will listen for
this event and pass the data to the levelInScreen .
The CustomEventScoreBoardUpdate.as class
This custom event will be used by the the Game.as class instance to update the values on the
ScoreBoard class instance. The Main.as class will listen to for this event and pass the data on to
the ScoreBoard.as class instance.
Search WWH ::




Custom Search