123456789101112131415161718192021222324 |
- extends Position2D
- var Ball: PackedScene = preload("res://labs/cascade/component/ball/Ball.tscn")
- export(Vector2) var dispersion_scale = Vector2.ONE
- export(float) var delay = 1
- func _ready():
- spawn()
- func spawn():
- var ball: PhysicsBody2D = Ball.instance()
- var dispersion = Vector2(rand_range(-1.0, 1.0) * dispersion_scale.x, rand_range(-1.0, 1.0) * dispersion_scale.y)
- ball.position = dispersion
- add_child(ball)
- get_tree().create_timer(delay).connect("timeout", self, "_on_delay_time_out")
- func _on_delay_time_out():
- spawn()
|