----------------------------
HUD - "ZL HEARTS"version 1.0
Attachment: HUD - ZL Hearts.zip----------------------------
- Explanation:
This stuff will help you to change the appearance of the health bar in your Solarus project.
The first heart represents the first four lives... OK stop! No further explanation!. A picture is worth a thousand words;
Example 1:
The original health bar (here, there are 15.5/20 hearts or 15.5 * 4 = 62 lives on 80) will be replaced by this smaller bar:
Example 2:
I played with the console to test "game:set_life()" and "game:set_max_life()"

-
Tested with Solarus v1.4.2-
IMPORTANT !!! Save your files before replacing them!- Copy these files in your Solarus project. The file path may differ from yours.
..\data\sprites\hud\
empty_heart.dat (There are 6 animations instead of 2 animations if you compare with the original data file.)
..\data\sprites\hud\
hearts.png (Some graphics are edited from a Zelda game. For copyright reasons, don't sell your project! )
..\data\scripts\hud\
hearts.lua (This file contains the main script edited from a original one by Christopho.)
..\data\scripts\hud\
hud.lua (It is not necessary to replace this file. The script contains a few more lines than the original created by Christopho. Keep yours and see below )
1st choice:
Copy the "hud.lua" file or add/replace these lines if you want to align element to right when the player wins a new heart container.
(...)
local hearts = hearts_builder:new(game)
hearts:set_dst_position(- (game:get_max_life() + 16), 6)
hud.elements[#hud.elements + 1] = hearts
local nb_max_hearts_displayed = game:get_max_life() / 4
(...)
local nb_max_hearts = game:get_max_life() / 4
if nb_max_hearts ~= nb_max_hearts_displayed then
nb_max_hearts_displayed = nb_max_hearts
hearts:set_dst_position(- (game:get_max_life() + 16), 6)
end
(...)
2nd choice:
Keep your "hud.lua" file if you want to align element to left when the player wins a new heart container.
Just adjust the x value of hearts:set_dst_position(-104, 6)
Perhaps you should also change the value of x hearts.surface = sol.surface.create(116, 11) in the "hearts.lua" file.
EDIT:- Erratum: For empty_heart.dat, I said there were "6 animations instead of 4 animations", but it's "6 animations instead of 2 animations"
- Images were hosted at an ISP, so I attached them directly at the forum, as I did with the .zip file.
You just have to be connected to see images.