How to create a complex HUD health bar? (SOLVED no need hardcode)

I want to make this health bar:
health%20and%20power%20bar
But no idea how to achieve these shapes in defold(I will also like to hear what you have to say of this health bar)

Thanks in advance(again rip you too many questions I ask)

Do you have sprites for this stuff, or wanna hardcode it?

I can make sprites but rather hardcode it

With sprites, You can just create a healthbar like this in 5 lines of code( I did that yesterday). So, I would recommend having sprites for this. As I am not pretty sure about the hardcoding part.

1 Like

Just say something like

if message_id == hash ("set_health") then 
self.max_health = self.max_health or message.health
local scale = gui.get_scale("healthbar")
scale.x = message.health/self.max_health
gui.set_scale(self.healthbar, scale) 
end 
2 Likes

dead%20player full%20power%20almost%20empty%20health full%20power%20half%20full%20health health%20and%20power%20bar

Ok I have this these are enough cuz player only have like 3 lifes kek

1 Like

btw @TheKing0x9 can you show me the health bar you made tho?

See it here (top left)

Or here(the healthbar above everyone’s head)

You should have asked some moments ago, I just closed my computer :frowning_face:, else I could have shown some clear ones too,

1 Like

why th the hud gui cant get the images from my healthbar.atlas wth

EDIT: Any texture in the atlas :thinking:

Just post a sample of what you are trying to do.

1 Like


set the texture to a texture from my healthbar.atlas

2 Likes

You need to add healthbar.atlas to the textures on the RHS of your gui. Then it will show up too :slight_smile:

2 Likes

Oh I see that now smh lol

2 Likes
gui.set_texture(node, "healthbar")
gui.play_flipbook(node, "live2")

EDIT: I have replaced set_texture(node to “Textures”/“Texture”)
And play_flipbook(node to “Box”/“box”)

What Am I getting wrong here?

1 Like

I solved it thanks @TheKing0x9

2 Likes