I’m trying to get my score counter to work when I kill enemies. I’m using the bitmap text feature. This is what I have so far, but the score does not change when an enemy dies? What am I doing wrong? I have my global variable linking to my level events too.
Yes, I followed the gem dev tutorial and made an external event and linked it from my main scene. Is there any reason why bitmap text would respond to code differently than normal text? In the tutorial he used normal text.
Edit:
I just tried the platformer template and changed it to bitmap text instead of regular text and it did the same thing. It broke the text. The code doesn’t work to change bitmap text. Does anyone know how to get bitmap text to work to keep score? Thanks.
I don’t know what you mean by text objects being big enough. When I drag my text onto the screen from the objects editor I can see my fonts just fine. If I copy what you’ve done, do I need to put code anywhere else to get it to work? Thanks.!
Ok. I used your code, made a global variable, added an external event, and linked the external event from my scene. When I kill said enemy, the score does not change? See here:
You don’t need all the stuff before the “+”…you just need “GlobalVariableString(Score)”. The stuff before the “+” is just something special I added for my game. This also needs to be it’s own event without a condition (as you had previously). You might try setting the initial value of Score to 0.
Then put it back so that when Enemy1 is dead it adds 10 to the global variable.
If that doesn’t work…the only other thing I can think of is are you sure “Enemy1 is dead” is true?
Thanks for your help on this. Ok so I changed it back, but put it as a global variable. What do you mean by “Enemy1 is dead” is true? Now my scene removes all the “000000” I have in my object ScoreText and just displays one “0” while playing the game? So something is working, but score does not add as enemies die.
The stuff before the “+” is what makes the Score always be a certain number of digits. You can cadd it back in if you prefer it that way.
The Action “add 10 to Score” won’t happen unless the Condition “Enemy1 is dead” is true. Double check to make sure that whatever Events you have to make Enemy1 die are actually happening.
You could test this by adding an Event that has a Condition of “at the beginning of the scene” and then an Action of “add 10 to the global variable Score”. If you test play the game and it starts with a 10 instead of a 0, then that could help narrow down the problem.
Ok. I wanted to make sure I’m selecting the right function. Under actions, I choose my text object “ScoreText” and select “text” to change the text right? See here: