How might I implement a segmented health bar (boss phases)?

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

I am working on a shmup, and right now, I want to connect the boss fight I made to a health bar. Like many shmups, the boss has multiple phases and I decided I wanted to implement it like the game Samidare.

Here’s a picture:

enter image description here

The top bar represents the boss’s total health, and the section that’s marked orange is the health of the boss’s current phase in reference to it’s remaining health.

The blue bar under it shows the current health of the current stage with no reference.

The bottom bar is easy enough, but I’m not exactly sure how to tackle the top one and I’ve come here to see if you guys might have any ideas.

Thank you.

:bust_in_silhouette: Reply From: Calinou

The top bar can be drawn using multiple ProgressBars stacked on top of each other (if you want to use styleboxes), or multiple TextureProgress nodes stacked on top of each other (if you want to use non-ninepatch textures).

I suggest making the bars span the entire width, and setting their progress accordingly. You could also put the progress bars within a HBoxContainer with its separation set to 0, but it may be more difficult to adjust in code.

Seemed simple enough. After like 45 minutes I think I got it to my liking

enter image description here

Thank you!

krosisbh | 2022-08-10 18:55