Game Development Reference
In-Depth Information
private function SortUser (array : UsersData[]) : void {
for (var i : int = 0; i < array.length-1; i++) {
for (var j : int = i+1; j < array.length; j++) {
//If the first score is lower than the second score swap
the position
if (_array[i].GetScore() <= array[j].GetScore()) {
var obj_temp : UsersData = array[i];
array[i] = array[j];
array[j] = obj_temp;
}
}
}
}
public function GetNameData(index : int) : String {
return as_users[index].GetName();
}
public function GetScoreData(index : int) : int {
return as_users[index].GetScore();
}
}
8. We are almost done. Finally, we will go back to the HiScore script to add some
scripts and enable the game to save and load the high score locally. Let's go back to
the HiScore script, at the line before the Start() funcion, and add the following
highlighted code:
private var b_isClickSubmit : boolean = false; //Checking if the
submit button is clicked by the user
private var obj_localHiScore : LocalHiScore; //Creating the
LocalHiScore Object
public function Start() : void {
//Initializing
9. Then, we will go to the Start() funcion and create the LocalHiScore object, as
shown highlighted in the following code:
public function Start() : void {
//Initializing
e_page = Page.GAMEOVER;
scrollPosition = Vector2.zero;
b_isClickRestart = false;
b_isClickSubmit = false;
 
Search WWH ::




Custom Search