show and hide images

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Yamz

Hello, I have a player who has three lives … lives are shown in one image each (the three images are a “+” sign)
I’ve tried to delete the image when the player loses a life … but I can’t make it reappear when I get my life back …
examples
He has 3 lives, loses one and hides an image with ($ Sprite2D.hide ()). Then he takes an object and recovers that life … he has 3 lives again … THE PROBLEM IS THAT I DON’T KNOW HOW MAKE THE IMAGE APPEAR NEWLY

if $One.hide() != true:
	$One.hide()
if $One.show() != true:
	$One.show()

Try this but it doesn’t work …

:bust_in_silhouette: Reply From: deaton64

Hi,

If you images are One, Two & Three and lives is called lives, you could use a simple Match statement:

match lives:
	0:
		$One.hide()
		$Two.hide()
		$Three.hide()
	1:
		$One.show()
		$Two.hide()
		$Three.hide()
	2:
		$One.show()
		$Two.show()
		$Three.hide()
	3:
		$One.show()
		$Two.show()
		$Three.show()