[Project Week 8.0] Health and mana text

Health and mana text

For this week I will be changing health and mana bar display a little, so instead of it juts displaying the green and blue bars that go up and down depending on the values, I will add text on the bars actually displaying the current health instead of just guessing. For example if the player is at 100 health it will display '100/100' and if the player has 5 mana left it will show something like '5/100' and so on. It's mostly a quality of life change and not crucial for the games development, but I think it works better for representing the health, and on top of that I plan on adding health and mana potions later so if they heal a certain number like '20' I would want the player to know exactly what health or mana they will be left with when consuming it, and stat text makes that possible.

Process

First of all I selected the health bar and added a 'UI text' which is simply text for the user interface. I then placed it on my health bar and for now put in the values 100/100.


I didn't like the default font so I changed it by importing a font that comes with windows, the font is a 'cartoony' font which fits with the theme of my game more



I also made it white



Then I duplicated the text for the mana. Here is what it currently looks like in game



Code

Simple bit of code to get the text functioning, this first bit just references the text on the health bar



Then within the same code that is used to change the values of my health bar I added this code which allows the text to be changed when the health values are changed



Here is a gif showing the health bar in action, as you see both the fill bar and the text values change when the health and mana value changes. (Note: I am using the 'I' and 'O' keys to change the values of the health and mana, this is only coded in for debugging purposes and wont feature in the actual game, it's just used to show the health and mana works)





Comments