GameDev : Lives System UI Visualization (Part II)!

Matteo Lo Piccolo
2 min readJun 17, 2021

--

To implement the “swap image system”, we need a method. In UI Manager we create this method called UpdateLives() and inside pass an INT parameter.

Now, try to understand what to do here

So, we need to ASSOCIATE our currentImage to the image in the Array, so we can swap it.

We take currentLive, and it is an image.
We use this syntax currentLive.sprite because we have an Array of Sprite, and we need a sprite to associate to a sprite ok?
And we associate to what?
To our Array of sprite, but the index inside is the currentLives.

We can delete Pseudo Code, go to Player script, and here we call the UpdateLives() method

UpdateLives() method

Here we have the Damage() method

When we take Damage, lives go down.
So exactly in that point we call UpdateLives()

We pass an INT value, and it is our current life!
So when life is three, the visual UI is three and so on.

Let’s try it

Perfect!!

--

--

Matteo Lo Piccolo
Matteo Lo Piccolo

Written by Matteo Lo Piccolo

Always in love with programming, even if late (I'm already 39 years old) I decided to follow my dream! We will see how far my passion will take me!

No responses yet