GDQuest / learn-gdscript

Learn Godot's GDScript programming language from zero, right in your browser, for free.
https://gdquest.github.io/learn-gdscript/
Other
2.11k stars 160 forks source link

Lesson 9: health progress bar shrinks on first `Reset` #220

Closed duianto closed 2 years ago

duianto commented 2 years ago

Is your feature request related to a problem? Please describe.

In the first and second code examples in lesson 9: https://gdquest.github.io/learn-gdscript/#course/lesson-9-adding-and-subtracting/lesson.tres

Pressing the Reset button shrinks the health progress bar slightly. Compared to when the lesson page was (re)loaded.

First example: Before: The progress bar ends to the right of the 5 in health = 75:

msedge_wSg4npiQ2e

After: The progress bar ends under the 5 in health = 75:

msedge_CeLrTzF2LD

The same thing happens in the second example:

Before: The progress bar ends under the first letter h in health = 25:

msedge_2FVJcEs71S

After: The progress bar ends below the left side of the first letter h in health = 25:

msedge_Ra0asO6iRi

Describe the solution you'd like The progress bar's initial size should probably match its reset size.

Note

This is most likely a low-priority enhancement. It doesn't affect the lesson's functionality. It's just an observation that pressing the Reset button, resizes the progress bar once, from its initial size.

mathmods commented 2 years ago

While indeed the original rect size value is wrong (it's calculated differently), it also calls the same function that reset calls to update it again.

It looks to me that something is blocking the tween from animating to the correct first size?

An easy fix would be to just update the original value to the correct one by using the same formula (190.0 * health / max_health). - And I would prefer using the empty health bars size as reference instead of the magic constant 190.0.