[Solved] Display score with bitmap text

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.

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 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:

Ok. So I did what you said and changed the condition for when the score changes, and it works! I changed it to when the player fires a bullet, now the score changes! I guess the problem now is how do I get the score to change when an enemy dies?

Put in the condition “Enemy1 is dead”.

I realise you had this earlier, but the results from your testing indicates the enemy isn’t marked as dead. So there is an issue elsewhere in your events that either doesn’t deplete the enemy’s health, or doesn’t reduce it enough, or you are using the wrong enemy object.

Ok. I opened a new topic on this problem. I will look into that and see what’s going on.