Score now briefly pops to a larger size as it increases in value.

This commit is contained in:
Henry 2026-01-03 18:08:32 +00:00
parent f1eec30167
commit 02d14e913c
5 changed files with 63 additions and 6 deletions

View file

@ -1,5 +1,7 @@
extends HBoxContainer
var last_score: String = "00000000"
var digit_coords = {
1: Vector2(0, 0),
2: Vector2(8, 0),
@ -14,11 +16,21 @@ var digit_coords = {
}
func display_digits(n):
var s = "%08d" % n
var start = 8 - str(n).length() # Finds the starting position of the counter by converting the score to a string, minus the leading zeros.
var changed = false
for i in 8:
get_child(i).texture.region = Rect2(digit_coords[int(s[i])],
Vector2(8, 8))
# var tween = create_tween()
# tween.tween_property(get_node("HBoxContainer/ScoreCounter/Digit0"), "scale", scale + Vector2(.5,.5), .15)
# await get_tree().create_timer(.25).timeout
# tween.tween_property(get_node("HBoxContainer/ScoreCounter/Digit0"), "scale", scale + Vector2(-.5,-.5), .15)
get_child(i).texture.region = Rect2(digit_coords[int(s[i])], Vector2(8, 8))
if i >= start and s[i] != last_score[i]:
changed = true
if changed:
for i in 8:
if i >= start:
var tween = create_tween()
tween.tween_property(get_child(i), "scale", Vector2(2,2), .15).set_trans(Tween.TRANS_BOUNCE)
tween.tween_property(get_child(i), "position:y", +5, .15).set_ease(tween.TRANS_QUART)
tween.tween_property(get_child(i), "scale", Vector2(1,1), .15).set_trans(Tween.TRANS_BOUNCE)
tween.tween_property(get_child(i), "position:y", -5, .15).set_ease(tween.TRANS_QUART)
last_score = s