[Solved] Display score with bitmap text


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.

Do you have something wrong with your BitMap?

The bitmap text just doesn’t change.

Does your BitMap Text Display Text? I mean in the scene editor, does it display any text?
If no, then it is a problem with your BitMap Font files.

Yes it displays just fine. My fonts are working. I just can’t get the code to respond.

Is it an external event? If so, have you linked to it from the main scene?

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.


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 have Bitmap fonts for Score and a few other items as external events, and it works for me. See below.

Are your text objects big enough to show the Bitmap font?

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.!

Is your Score a Global or a Scene variable? Your code is changing a Scene variable, but maybe it should be Global?

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.

1 Like

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:

Also, I just thought, do I need some sort of code that starts the score counter at the beginning of the scene?

You can either do it via an action, or go here and set the initial value of Score to 0.

How do I set the inital value of score to 0 from Global variables? I’m sorry, very new to coding in general.

Just type it in in the field right next to it:

Thanks. Which text do I choose? Modify text or Text bitmap text? See photo: