Displaying Lives
I have now integrated a graphical representation of a player’s remaining lives into my space shooter game. Setting this up came with its own set of new challenges.
The first thing I needed to do was create a representation of the image on the screen in Unity. I did this by creating a new UI image inside of the Canvas, and applying the “3 lives” sprite to it as a default.
Next, I updated the UI manager script to include an array of four sprites to store the various images needed to execute the lives display. I also added a method to update the lives image when called on by the player object.
After that was all finished, I just needed to apply the UI image representation into the logic to be updated. And with that, I have a functioning lives counter.