Mysterious gui object?

continuing my heart system, using a cloned database to keep track of the hearts. however I found this issue that at the end of my health bar, there is one heart which a: doesn’t have a id (i’ve printed and emptied the whole table and its still there), I’ve been trying to fix it but I don’t know what it is or why its there, its not the original heart which I’m cloning from either. Any help would be appreciated


after I took two hits of damage

Are you aiming for ten hearts? The while loop happens 11 times. It goes from 0 to 10 (less than or equal to hearts).

1 Like

I’ve fixed that now. however the invincible mystery heart is still present

To enable and disable gui you should use gui.set_enabled(). You will need to enable the gui before cloning and then disable after you are done. API reference (gui) (defold.com)

2 Likes

Try

function init(self, dt)
self.hearttable= {}
	for i = 10 do
		-- this code will be run ten times
		self.hearttable[i] = gui.clone(gui.get_node("heart1")
	end

this will create a table with 10 hearts in it.

Is it the original heart that you have cloned 10 times?

yes

yes this fixed it. thank you!!

1 Like