pegchamp/HUD/BallCounter.gd

12 lines
358 B
GDScript3
Raw Normal View History

2021-09-08 08:27:14 +00:00
extends Sprite
func _ready():
var _balls_connection = GameStats.connect("balls_changed", self, "set_balls")
set_balls()
func set_balls():
if GameStats.balls_left >= 1:
var old_region_size = get_region_rect().size.y
var new_region = Rect2(0, 0, old_region_size * GameStats.balls_left - old_region_size, old_region_size)
set_region_rect(new_region)