Hello everyone, I am new to defold
I want to develop a game that includes a health bar and make it to gradually decrease to a certain length when the player is injured.
Since I want the health bar to be pinned to the game screen without being affected by the camera, I have set the health bar in the GUI.
I wanted to test reducing the health bar by half, but unfortunately, the entire health bar decreased until it disappeared. What is wrong with my code?
health_bar.gui_script
function init(self)
local healthbar_node = gui.get_node("bar")
local size = gui.get_size(healthbar_node)
gui.animate(healthbar_node, "scale.x", gui.PLAYBACK_ONCE_FORWARD,0.5, go.EASING_INOUTSINE)
end
If I don’t place the health bar in the GUI but put it in a go, using the following script works successfully. However, placing it in the GUI is unsuccessful.
go.animate("go#health_bar", "scale.x", go.PLAYBACK_ONCE_FORWARD, 0.5, go.EASING_INOUTSINE, 1)
What did I do wrong? Thank you.