Ok, you need to come to learn when events trigger. A lot of using gE is knowing when certain events will trigger and which ones of those are appropriate for the tasks you want. In this case create actor only happens once, so would putting it there make sense? That bit of code only gets looked at once when the actor is created, so that means score has to already be 1000 when the actor is created.
Now draw actor happens every frame. Since you are checking for when score is greater than 1000, that could happen at any time, and therefore you would have to check every frame. But since draw events execute every frame this poses the following problem. If score is greater than 1000 then Lives will be increased every frame. That currently is what you are having problems with. There are a couple of ways of fixing this. If score is allowed to be reset (as in lowering it by 1000 is okay) then doing that will work. But since you are using a text actor to display it probably that isn't the case. You could do something like this though (create a variable called next_life).
- Code: Select all
if(score>next_life)
{
next_life+=1000;
lives++;
}
Two things about that, next_life will need to be set to 1000 at the start of your game, the other thing is I recommend you stay away from using textNumbers like that. They aren't a good replacement for real variables, as there have been many reports of textNumbers causing unpredictable behavior. So, instead you should only set textNumber to something, instead of using it in comparisons. You say you have said variables so use them. Usually people just add a draw event to their text actors that displays their variable.
life_display -> Draw Actor -> Script Editor
- Code: Select all
textNumber=lives;