Game Development Reference
In-Depth Information
These are the simple custom event constants:
GAME_OVER
: Dispatched to
Main
to change state to
STATE_SYSYEM_GAME_OVER
NEW_LEVEL
: Dispatched to
Main
to change state to
STATE_SYSTM_NEW_LEVEL
The complex custom events needed for this game are few. We will need some basic events for
Main
to update the
ScoreBoard
class that we will create for this game. These
CustomEventScoreBoardUpdate.UPDATE_TEXT
events pass two variables in the custom events
object:
Key
and
Value
. We also have to pass
CustomEventLevelScreenUpdate.UPDATE_TEXT
to
Main
(
CUSTOMEVENT_SCORE_BOARD_UPDATE
). This simply passes the new level value in the custom
event object. The custom events, along with the key/value pairs they pass, that we will be using
are as follows:
Updating the score on the scoreboard:
Event
:
CustomEventScoreBoardUpdate.UPDATE_TEXT
Key
:
Main.SCORE_BOARD_SCORE
Value
:
0
for a new game or the current
score
during game play
Updating the clicked text on the scoreboard:
Event
:
CustomEventScoreBoardUpdate.UPDATE_TEXT
Key
:
Main.SCORE_BOARD_CLICKED
Value
:
0/0
for new game and level or
clicked + "/" + numCircles
during
game play
Updating the percent needed on the
scoreBoard
Event
:
CustomEventScoreBoardUpdate.UPDATE_TEXT
Key
:
Main.SCORE_BOARD_PERCENT_NEEDED
Value
:
0%
for new game or
percentNeeded
during game play for new level
Updating the percent achieved on the
scoreBoard
Event
:
CustomEventScoreBoardUpdate.UPDATE_TEXT
Key
:
Main.SCORE_BOARD_PERCENT_ACHIEVED
Value
:
0%
for a new game or
percentAchieved
during game play for new level
Updating the level number on the
levelInScreen
Event
:
CustomEventLevelScreenUpdate.UPDATE_TEXT
Key
:
“level” + level
variable
Defining the game-specific custom classes
When we need more than one instance of an object and if those objects will each need to store
unique data about themselves, we usually create a custom class for the object. We will create the
following custom classes for the circles that need to be clicked and also for displaying the score
the player received for clicking on a circle:
Circle
instances will contain data for a type (
GOOD
or
BAD
) and whether or not they have
been clicked.