score label vfx; increase building collider size
This commit is contained in:
parent
69faf54dc3
commit
962c4cb469
6 changed files with 60 additions and 18 deletions
|
|
@ -1,12 +1,35 @@
|
|||
extends Label
|
||||
extends Control
|
||||
|
||||
const DESIRED_SCALE := Vector2.ONE * .5
|
||||
|
||||
@onready var label: Label = get_child(0)
|
||||
var tween: Tween
|
||||
var _display_score := 0
|
||||
var score := 0:
|
||||
set(v):
|
||||
var delta = abs(v - score)
|
||||
score = v
|
||||
text = "Score: %d" % v
|
||||
|
||||
if label != null:
|
||||
if tween != null: tween.stop()
|
||||
tween = create_tween()
|
||||
tween.tween_method((func(n):
|
||||
_display_score = n
|
||||
label.text = str(n)
|
||||
), _display_score, score, .25)
|
||||
|
||||
scale += Vector2.ONE * pow(delta, 1.25) / 400
|
||||
|
||||
func exp_lerp(a: Variant, b: Variant, decay: float, dt: float) -> Variant:
|
||||
return lerp(a, b, 1 - exp(-decay * dt))
|
||||
|
||||
func _ready() -> void:
|
||||
scale = DESIRED_SCALE
|
||||
score = score
|
||||
SignalBus.building_destroyed.connect(func(_building):
|
||||
score += 10
|
||||
SignalBus.building_destroyed.connect(func(_building, increment):
|
||||
score += increment
|
||||
)
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
scale = exp_lerp(scale, DESIRED_SCALE, 05, delta)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue