How to add score?

Hi.
I have a problem with some score

I have a currentscoe that gets score from i string input.

currentScore = Text.stringToEdit.Length;

So if i write a word with a length og 5, the current score is set to 5.
But when i press enter, and the input field is set to empty the score disaper.
how do i save the score?

I also have another problem. this is to add more “value” to the score.
exampel. If i have 5 point on the first word i write, press enter, and write in a new word with a length og 8, the score should be sett 13. how do i add the score togehter?

thanks=)

Can you plz show ur code?

1 Answer

1

make a int variable in your class.

int score;

currentscore = Text.stringToEdit.Length;

score+=currentscore;

Add the currentscore value to the score value. Keep on adding value to it on each enter you press.

Thanks for the answer. I have tried you solution, but if i do it that way, the score keep adding like crazy. it's like the score get's added in every frame, so the score gets up to 1000 in few seconds.

just add score when u hit enter or when u clear your text field. Not in the Update().

that helped a lot=) thanks

Do tick mark, if this solved ur issue.