Game Development Reference
In-Depth Information
Playing Soundtracks in Main.as
The first major piece of code we will discuss is
Main.as
. Much of the
Main.as
class for Dice Battle
is similar to that of Color Drop. However, there are two major differences that we are going to
discuss: the
ScoreBoard
and playing soundtracks.
Revamping ScoreBoard
For Dice Battle, are going to create a scoreboard that is more elaborate than anything we have
created thus far. While this code is not intricate or tricky, we are going to discuss this because it
demonstrates how the
ScoreBoard
object can be used for more intricate designs than we have
previously created.
Notice the game screen for Dice Battle in Figure 9-4 where we have highlighted the five
scoreboard elements.
Figure 9-4.
Dice Battle screen with scoreboard text highlighted
These are the Dice Battle scoreboard elements:
The player's score
The current game level
Player's hit points
Computer hit points
Turn indicator
All of these elements are necessary to let the player know what is happening in the game. To
support these elements we need to create some additional
TextFormat
objects.