I make a game with highscores. If you play the game and you earned by example 1000 points. and the next time, if you play the game again and you earned 1200 points. then the highscore will be 1200 and not 1200+1000=2200 points. and if you play again and you earned 800 points, the highest score will stay.
This is a better example:
1st time play: 1000 points (this is the highest score), score shows 1000 points
2nd time play: 1200 points (higher than the 1st play, new highscore), score shows 1200 points
3rd time play: 800 points (lowest score), score shows the highest score, 1200 points.
Well these are the Js I use. Someone whoe can help me fix that.
In the play scene:
var ScoreSkin:GUISkin;
static var s1lvl1Score: int;
InvokeRepeating("Add",0, 0.1);
function Add() {
s1lvl1Score += 1;
}
function OnGUI(){
GUI.skin = ScoreSkin;
GUI.Box(Rect(Screen.width*0.475,Screen.height*0.9,200,35), s1lvl1Score.ToString());
GUI.Label(Rect(Screen.width*0.375,Screen.height*0.9,200, 35), "SCORE :");
}
In the menu scene were the highest score will show:
static var Season1TotalPoints = true;
var ScoreSkin:GUISkin;
static var season1points: int;
InvokeRepeating("Add", 0, 0.0);
function Start() {
DontDestroyOnLoad(gameObject);
}
function OnGUI(){
GUI.skin = ScoreSkin;
if (Season1TotalPoints){
GUI.Box(Rect(Screen.width*0.09,Screen.height*0.68,200,35), season1points.ToString());
}
}
The finish what adds the points:
function OnTriggerEnter(other : Collider){
if (other.gameObject.CompareTag("Tag")) {
Season1_Score.season1points += ScoreS1lvl1.s1lvl1Score;
}
}
Someone help please