32 lines
856 B
GDScript3
32 lines
856 B
GDScript3
|
extends Sprite2D
|
||
|
|
||
|
@export var bottle_speed: float = 120;
|
||
|
|
||
|
var tim_global_position: Vector2
|
||
|
var is_hidding: bool
|
||
|
|
||
|
# Called when the node enters the scene tree for the first time.
|
||
|
func _ready():
|
||
|
tim_global_position = get_node("/root/IngameScene/Stage/Tim/ThrowPoint").global_position
|
||
|
|
||
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||
|
func _process(delta):
|
||
|
var t = create_tween()
|
||
|
t.tween_property(self, "global_position", tim_global_position, 3.0)
|
||
|
t.tween_callback(remove_bottle)
|
||
|
|
||
|
func _on_bottle_area_entered(area):
|
||
|
is_hidding = true
|
||
|
|
||
|
func _on_bottle_area_exited(area):
|
||
|
is_hidding = false
|
||
|
|
||
|
func _on_growth_timer_timeout():
|
||
|
var t = create_tween()
|
||
|
t.tween_property(self, "scale", self.scale + Vector2(0.01, 0.01), 0.02)
|
||
|
|
||
|
func remove_bottle():
|
||
|
if is_hidding:
|
||
|
print("Ouch")
|
||
|
queue_free()
|