I think you understood really well how it works. To answer your questions:
- the Array is used to store the UID of each segment in order. This way it is possible to switch visibility state of specific section of the bar. This is where the magic reside.
- gameData is used to keep data between layout switch. In this case the player HP.
Since I posted this, I found another way to do it. I needed a round HP bar. This solution need only one sprite. This sprite could be any shape. This shape should be filled with a gradient from a solid color to transparency. Then you apply this effect to your sprite. You set "Smoothness" to 1 and "Flat Colors" to 1. By changing the "Threshold" parameter from 0 to 100, you should see the sprite gradually appear or disappear. Here's an example .capx
The effect is not perfect but I haven't worked a lot on fine tuning this.
The alpha threshold effect I used can be replace by 'vanilla' effect but I preferred the result with this one.
To change the color of your sprite, you simply rotate the HUE with the effect "AdjustHSL".
If you want to also move the "other side" of the bar, I guess you can simply rotate the sprite at the same time.
I hope it is not to confusing.