Game Development Reference
In-Depth Information
//pl2 score, not implemented
GUI.Label (Rect
(Screen.width-200, 5, 200, 40),
"SCORE <2>");
GUI.Label (Rect
(Screen.width-200, 20, 200, 40),
"0");
//hiscore
GUI.Label (Rect ((Screen.width/
2)-100, 5, 200,
40), "HI-SCORE");
GUI.Label (Rect ((Screen.width/
2)-100, 20, 200,
40),
DisplayScore.HiScore.ToString());
}
The numerical values to define the coordinates for the text to be displayed may vary
according to the setup of your project and your game window dimensions, so tweak
them as needed.
Now that we have correctly positioned our text on the screen it is time to have the
score updated during the gameplay; we will do that with a dedicated script.
1. Create a new JavaScript file and name it ManageScore . Open it with
MonoDevelop and create two static variables: one for the actual PL1 score
and one for the HiScore . The reason we declare these variables as static is
to allow the DisplayGUI script to access their values.
2. In the Start() function, add the following lines to set the initial values of
Score and HiScore variables:
#pragma strict
static var Score:int;
static var HiScore:int;
Search WWH ::




Custom Search