- Home /
How many different scripts do I need to write to create a highscore system?
I am trying to create a single highscore on Android OS that displays in my first scene and is saved there so when the player returns their highscore is saved and displayed. I'm just trying to get a handle on the order of things. Thanx
Generally:
How many separate scripts will it take to accomplish this?
How many empty game objects will I need to create for these scripts if any?
How many GUiText objects will I need?
Can all of my scripts lay on one game Object to complete this task?
Thanx again.
This is my current score script which sits on a GUIText Object in my second scene and it works perfectly.
` var r : float = 1;
var g : float = 0;
var b : float = 0;
var a : float = 1;
static var Score : int = 0;
function Start(){
Score+=100;
guiText.text = "Score: "+Score;
var color : Color = Color (r, g, b, a);
// Change the material to display green text.
guiText.material.color = color;
}
function AddPoints() {
Score+=100;
guiText.text = "Score: "+Score;
}
function Awake() {
Score = 0;
}
function Reset(){
Score = 1400;
}
Answer by DaveA · Sep 06, 2011 at 10:04 PM
You need as few as one game object and one script, but if you want to break things up for some reason you can put multiple scripts on one object. Have as many GUITexts as you want. You may also want to look at GUI.Label instead. Or GUILayout.Label
So can I just add my PlayerPrefs commands on the script above?
Yes you can. Note: not sure why you separate r,g,b,a like that, you can declare a Color like var originalColor Color = new Color (1,0,0,1) and later do var c = originalColor; or whatever.
Your answer
Follow this Question
Related Questions
Is it necessary to create an Array() to show high scores in PlayerPref? 1 Answer
PlayerPrefs HighScore problems, it doesn't work. 4 Answers
PlayerPref set int and get int 1 Answer
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
How do I save highscore (Very Simple) 3 Answers