How to add a highscore Tutorial

Learn how to make certain types of games and use gameEditor.

How to add a highscore Tutorial

Postby again » Thu Feb 24, 2011 3:40 am

Your going crazy because you dont know how to save your highscore, well now you do , lets get it.

Step by Step



Now name your highscore actor highscore ok before starting the rest. Also name your regular score actor score ok that make this easier and bug-free.

1)Go to global code(the gray tab on top bar of screen)click on the variable tab / click on add /fill it in like this /

NAME: hscore
SAVEGROUP: nscore

2) Ok go click on your player( the person you controling) click on collision , pick any object that kills you, and put this code in script editor

Code: Select all
saveVars("h.file","nscore");
hscore=highscore.textNumber;


3)ok now go click on the highscore actor( make sure the name of highscore is highscore) now click on create actor and go to script editor
and put this code in

Code: Select all
loadVars("h.file","nscore");
highscore.textNumber=hscore;


4th and final step (yes its almost over) Click on your highscore / click on draw actor / and put this code

Code: Select all
if(score.textNumber>highscore.textNumber)
{
highscore.textNumber=score.textNumber;
hscore=highscore.textNumber;
}


Thats it your done and it will work . If in the crazy case it doesnt , look over the code. Remember to name your regular score name it score and your highscore name it highscore. Also on your computer a h.file will be in the folder. Thats your highscore save file so dont worry its not something wierd. Best of luck!!!!
Free windows mobile games like doodle jump and super mario bros
http://krenisis.freeforums.org/
again
 
Posts: 258
Joined: Wed Jan 19, 2011 7:06 pm
Score: 33 Give a positive score

Re: How to add a highscore Tutorial

Postby again » Fri Feb 25, 2011 1:27 pm

What you have now accomplish is something advanced , a major achivement as saving is a difficult part of game making.

1) Made a variable and put it in a save group (name, save group)
2) Made the variable equal the highscore ( highscore.textNumber=variable)
3) Now when you die you made the variable saved and made a separate file which to save ( saveVars " your made up file""save group your variable is in")
4) Finally you made the variable load in the highscore when the game starts (loadVars"your made up file name" "save group your variable is in" )

If for some reason you had trouble please feel free to ask question. If you would like a demo I made a fun game called Mario Kart Mini in the game demo section so you can see highscore in action. Play this game to see highscore being saved.

viewtopic.php?f=6&t=9119
Free windows mobile games like doodle jump and super mario bros
http://krenisis.freeforums.org/
again
 
Posts: 258
Joined: Wed Jan 19, 2011 7:06 pm
Score: 33 Give a positive score


Return to Tutorials

Who is online

Users browsing this forum: No registered users and 0 guests

cron