Hi everybody,
I’m going to make my own game in Unity and i wanted to know something very important.
I am making a memory game, with a color code (pink, red, blue and green).
I just wanted to put a counter when i makes a pair of two colors (for example, when i makes a pair of two pink cards, the counter display 1 point for the pink color)
I hope i was clear enough for you, it may be confused (i’m french =)
The simplest way to add some counter to your game is using GUIText. Click the Create button in the Hierarchy panel and select GUIText. Adjust font, size, style and position, then add a script to change its text property to the points reached. An easy way to do it is to have a static var in the player script, than read it in the GUIText script:
// player script (let's name it Player.js):
static var points:int = 0;
// when the player gains points:
points += pointsToAdd;
// In the GUIText script:
function Start(){
guiText.material.color = Color(0.8,0.8,0.1,0.5);
guiText.text = "";
}
function Update(){
guiText.text = "Points: "+Player.points;
}
Thanks man, that’s exactly what I wanted. So I guess i have to make four GUI text, because i have four colors ? And each time I have to change the numbers in “material color” right ?
Another question, how can I know the numbers of my colors ?
I also want to add a system that will respawn cards when I make a pair. I spend a lot of time on this, but this is very difficult.