I made a game with this kind of health bar, it is very simple (don't be scared by the length, it is very detailed) :
- create a "heart" sprite
- create a specific layer to put the "health bar" (can be skipped)
- create an event at the start of layout (or at the start of your game) :
repeat 3 times :
create heart on layer "health bar" in (50+50*loopindex() , 50)
this create the hearts in (50,50) ; (100,50) ; (150,50)
the values "50" can be replaced if you want to place your hearts at a different position.
- add a condition to the event where the player lose a life, you must already have created :
heart : pick nearest to (720, 0)
this pick the heart at left (even if there is more or less hearts)
You can also change the value "720"
- add a sub-condition to this event :
compare 2 values : heart.count > 0
- and the action corresponding :
heart : destroy
- you can add a "Else" condition : that means the player lose, there is no heart left.
in few words:
repeat 3 times : create heart on layer "health bar" in (50+50*loopindex() , 50)
heart : pick nearest to (720, 0)
- if heart.count > 0 : destroy heart
- else : player lose