@savvy:
I wouldn't advice anyone to use textNumber, because then they will start using it as variable, but as you may have noticed, it doesn't fit for use like variables.
@praaab:
You'd need to make variables for score and lives and then print them on screen.
It goes like this:
We need two integer variables, score and lives
1. Go to script editor (in any event), click variables and click add.
2. Then name it score, leave it to be global and integer. Then just press add.
3. Do the same again but name variable as lives.
4. Now you can use your score and lives variables to hold the numbers.
You can have something like:
Player - collision any side of enemy - script editor:
- Code: Select all
lives -= 1;
That code would take 1 life away when you collide with enemy actor.
5. What comes to showing variables on screen, create two actors, showScore and showLives.
Give these actors some font in "Text" option and set their text to be a few 0's.
Then go to showScore - draw actor - script editor:
- Code: Select all
sprintf(text, "%i", score);
That code will make the actor show the score.
And finally, for showing the lives, go to showLives - draw actor - script editor:
- Code: Select all
sprintf(text, "%i", lives);
That sprintf() is a function for setting text.
What we did now was set the event actor text to be the number we wanted.
sprintf() needs two arguments, destination string and source string.
The destination string was text, which means current actors text. We could've used showScore.text. as well, but there was no need for it because we were in the showScore actors event.
The source string is the one inside " and ". We had here %i which means that we want to add an integer variable to the string. And finally, after the source string marked with " and " we had score, which means that we will place the value of the variable named score to the source string to the place where the %i is.
I wish that helped you!
Ask if you still need help understanding it.
- lcl -