Quantcast
Channel: Questions in topic: "playerprefs"
Viewing all articles
Browse latest Browse all 1333

Highscore GUI not working properly help

$
0
0
I've manage to set and show a score after the player game is over, only thing wrong is when i ever beat the highest score, it doesn't show "New Highscore" it shows "Score:(Number of points earn during the game)". I want it to display New Highscore whenever the player beats their highscore, if you can help me with this thank you! public GUIText scoreText; int score; int highScore; bool newHighScore; void Start () { score = PlayerPrefs.GetInt ("Score"); if (!PlayerPrefs.HasKey("HighScore")) { PlayerPrefs.SetInt("HighScore", score); newHighScore = true; highScore = score; } else { highScore = PlayerPrefs.GetInt("HighScore"); if (score > highScore) { newHighScore = true; PlayerPrefs.SetInt("HighScore", score); highScore = score; } else newHighScore = false; } } public void AddScore (int newScoreValue) { score += newScoreValue; UpdateScore (); } void UpdateScore () { scoreText.text = "Score: " + score; } if (playerLives == 0 && player == null) { GameOver(); if (newHighScore) GUI.Label (new Rect (Screen.width / 2 - 100, Screen.height / 2 - 10, 500, 100), "New High Score: " + score, "label"); else GUI.Label (new Rect (Screen.width / 2 - 100, Screen.height / 2 - 10, 500, 100), "SCORE: " + score, "label"); }

Viewing all articles
Browse latest Browse all 1333

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>