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

#1

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)

0 Likes

#2

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

0 Likes

#3

I can make sprites but rather hardcode it

0 Likes

#4

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

#5

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

#6

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

#7

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

0 Likes

#8

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

#9

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

EDIT: Any texture in the atlas :thinking:

0 Likes

#10

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

1 Like

#11


set the texture to a texture from my healthbar.atlas

2 Likes

#12

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

#13

Oh I see that now smh lol

2 Likes

#14
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

#15

I solved it thanks @TheKing009

2 Likes