I’m trying to make a hp bar with no max capacity, the more hearts you gain the more hearts render in the gui, in terms of numbers this is fine but I’m having difficulty displaying these hearts in the UI, I’ve been able to draw the hearts on screen with my redraw function, but the issue comes when It comes to taking damage, I need to find a way to keep tabs on the order of hearts and delete the one furthest to the right, I thought I could go about this by after every time I take damage, I delete all the hearts and redraw them one less, this works for the first heart of damage but then fails to remove any more hearts, any ideas on potential fixes or alternate methods appreciated.
I don’t see that in this code. You’re only deleting one node in refresh()
, so you must be getting a ton of duplicate hearts.
I think you’re making it too complicated. Just spawn the hearts you need in the beginning, and store the nodes in a list. When you take damage, delete the last node in the list.
Also you’re missing the 'end'
to close the redraw
function, which is going to break all the code after it (and crash on load unless you have an extra 'end'
somewhere it doesn’t belong later).
3 Likes