Game Development Reference
In-Depth Information
if (GUI.Button(new Rect((Screen.width - 240)*0.5, (Screen.
height*0.1) + 200, 240, 30), "SUBMIT")) {
b_isClickSubmit = true;
//TODO: Submitting both local and server high score here
}
}
//Creating the Local Hi-Score page button
if (GUI.Button(new Rect((Screen.width - 240)*0.5, (Screen.
height*0.1) + 240, 240, 30), "LOCAL HI-SCORE")) {
e_page = Page.LOCALSCORE;
}
//Creating the Server Hi-Score page button
if (GUI.Button(new Rect((Screen.width - 240)*0.5, (Screen.
height*0.1) + 280, 240, 30), "SERVER HI-SCORE")) {
//TODO: Loading the score data from server here
e_page = Page.SERVERSCORE;
}
}
5. Next, we will create the LocalScorePage() funcion. This funcion will load the
high score from the player's local machine and display it on the menu. This menu
will include the scrolled area and scroll bar to show the player's score data. Let's
create the LocalScorePage() funcion as follows:
//Loading the local scores
private function LocalScorePage() : void {
//Creating the background box
GUI.Box(new Rect(Screen.width*0.1, Screen.height*0.1, Screen.
width * 0.8, Screen.height * 0.8), "LOCAL HI-SCORE", GUI.skin.
GetStyle("Box2"));
//Creating the scrolled area and scrollbar to view the player
scores
scrollPositionL = GUI.BeginScrollView (new Rect ((Screen.width
- 320)*0.5, (Screen.height*0.1) + 80, 320, 180), scrollPositionL,
new Rect (0, 0, 300, 30*maxUsers));
for (var i: int = 0; i < maxUsers; i++) {
//Setting the number of the user
GUI.Label(new Rect(0, i * 30, 35, 30), (i+1).ToString() +
".");
//TODO: Showing the user name and score here
}
GUI.EndScrollView (); //End Scroll Area
if (GUI.Button(new Rect((Screen.width - 240)*0.5, (Screen.
height*0.1) + 280, 240, 30), "BACK")) {
e_page = Page.GAMEOVER;
}
}
 
Search WWH ::




Custom Search