As seen from the title, i would like to ask how am i going to display the values in the array in the scenes.
The flow go like that:
static var previousWord : Array = new Array();
The player will form about 6 words in order to proceed to the next level.
So every word form, it will be add to the array ->previousWord.Add(thisword); So after all the 6words form and stored in the array. It will proceed to the next scene to show “LEVEL COMPLETED” and i want to display all the six words form by players.
var word : Transform;
function Start ()
{
for (var j : int=0; j < gamecontrol.previousWord.length; j++)
{
word.guiText.text = gamecontrol.previousWord[j];
print(gamecontrol.previousWord[j]);
}
}
→ this is what i have done. i try printing the word formed and i get the 6 words print on the console. But when it come to display, it print the last word form. Meaning like player form “ate,apple,add,adore,boy,girl”, it only display girl instead of the “Ate,Apple,Add,Adore,Boy,Girl”?
So i want it to display as :
Number of words formed : Ate
Apple
Add
Adore
Boy
Girl.
What you’re doing is in each loop you’re replacing guiText.text and not adding to it.
Try this instead:
word.guiText.text = ""; // blank the last frame's text
for (var j : int=0; j < gamecontrol.previousWord.length; j++)
{
word.guiText.text += gamecontrol.previousWord[j] + "/n"; // add a new line
}
Just to add on, for example player click on the word, i want the color to stay on instead of going back to the original color. Don’t know if you get what i am asking. For example, initially the color is white, so when player’s mouse over the text, it will turn to blue but when the mouse exit it will turn to the original color “white”, how can i retain the color blue? Because i want to let the player know which alphabets they have clicked.
function OnMouseEnter()
{
guiText.material.color = Color.blue;
}
function OnMouseExit()
{
guiText.material.color = Color.white;
}
I got another question.
For example player finish playing level1. But the player instead of proceed to the next level, they click to the main menu. So when they feel like continue the game, i want them to go to level 2 instead of the level 1 that they have already play and complete. How do i solve it??