Since there actually isn't an object that handles a list of highscore I devised a method to do so in my game. Please correct or simplify it if you can do so. Some of it is in code, other bits are just descriptions. I'm not a wiz at coding so if this is wrong please point that out too.
Assumptions:
hsnumb[1...11] = int.
hsname[1...11] = str.
score = int.
name = str.
hsnumb[z] corresponds to hsname[z] (score and name)
there are 10 places in the highscore
Code:
/// for loop
///
for(z=10;z>0;z--;){
if(hsnumb[z]<score){
hsnumb[z+1] = hsnumb[z];
hsname[z+1] = hsname[z];
hsnumb[z] = score;
hsname[z] = name;
}
else
break;
}
/// end of loop
///
Description:
So here's what I did. I initiated a for loop. It starts at 10 and finishes at 1, I hope. If the variable i is not greater than 0 it ends the loop.
If the statement is true then it checks if hsnumb[z] is less than 'score'. If so then hsnumb[z] will be placed 1 below that of itself which would be hsnumb[z+1]. hsname[z] will also be substituted into hsnume[z+1].
Then that same array is substituted by the new score and new name, that is, hsnumb[z] = score, hsname[z] = name.
If the 'If statement' is not true then the whole loop ended since there is no need for it.
Essentially this code systematically goes through the highscore list from 10 to 1 to see if the new score is greater than any one of them. It starts from the bottom since it seemed to be logical and less convoluted from starting from 1. It checks to see if 10th score is less than the new score. If it is true then 10th score is put into a non existing 'garbage' (11th place) which is not displayed nor saved, it is just there as a place holder in prevention of a logical error. After that the 10th place is replaced by the new score (+name).
This code then loops to check the 9th place to see if the new score is greater. If so then substitutions similar to the 10th place mentioned above occurs. 9th score is subbed into 10th score (which was new score) and the new score now subbed into 9th.
The whole process continually repeats until it reaches 1st place or the new score is less than the place it's currently being compared with.
I assume this works in a C++ coded game but I don't know if it's fully possible in the event sheet of CC.
If there's already a tutorial about this without a cap file then I shall initiate a face palm procedure. If you did not understand the code then learn Arrays and For loop.
Please tell me if this is right because I don't want to think about this for any longer. I'm moving onto my highscore save methods.