O'Reilly logo

Getting Started with Unity 5.x 2D Game Development by Francesco Sapio

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required