Game Development Reference
In-Depth Information
//Creating the array of UsersData object
as_users = new UsersData[int_maxUser];
//Creating the array of int to store all the user scores data
var a_scores : int[] = new int[int_maxUser];
for (var i: int = 0; i < int_maxUser; i++) {
//Creating the user data object, load data, and store it to
the UsersData array
var obj_user : UsersData = new UsersData();
obj_user.LoadLocal(i);
as_users[i] = obj_user;
a_scores[i] = as_users[i].GetScore();
}
//Getting the minimum score for the save data purpose
int_minScore = Mathf.Min(a_scores);
}
}
6. Then, we will add the SaveGame (scores : int, name : String) and
SortUser (array : UsersData[]) funcions to sort the user data and save it
to the local machine after the LoadGameLocal() funcion, as shown highlighted in
the following code:
class LocalHiScore {
//Above Script
//////////////////////////
public function LoadGameLocal () : void {
//Creating the array of UsersData object
as_users = new UsersData[int_maxUser];
//Creating the array of int to store all the user scores data
var a_scores : int[] = new int[int_maxUser];
for (var i: int = 0; i < int_maxUser; i++) {
//Creating the user data object, load data, and store it to
the UsersData array
var obj_user : UsersData = new UsersData();
obj_user.LoadLocal(i);
as_users[i] = obj_user;
a_scores[i] = as_users[i].GetScore();
}
//Getting the minimum score for the save data purpose
int_minScore = Mathf.Min(a_scores);
}
public function SaveGame (scores : int, name : String) : void {
 
Search WWH ::




Custom Search