Implementing the sugar meter
If in the previous section we have seen how the sweet-tooth pandas can defeat the player, now it's time to give the player a way to stop them. The first step is to have enough sugar to build cupcakes towers. As such, we need a sugar meter to keep track of the amount of sugar that the player possesses.
As we have seen in our design, this will be a number, and not a bar like the health. Therefore, even if the concepts are similar, the implementation is slightly different.
Creating and place
The process for creating the sugar meter is similar to the health bar, so let's start to create a new Image, parented with the Canvas, named Sugar_Meter
. As a Sprite, you can use the ui_sugar_meter
file in the Graphic/UI
folder. Place it, and scale it if necessary, in the scene to match the following screenshot:
Next, create a Text component, parent it to Sugar_Meter
, and name it Sugar_Meter_Text
. You can set the font and the color that you prefer. At the end you should have something...