gae_wild_jam/scripts/DropsBase.gd

33 lines
1.1 KiB
GDScript

extends Area2D
class_name DropsBase
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
_animate_spawn()
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass
func _get_random_landing_position() -> Vector2:
var offset_x = randf_range(-20,20)
var offset_y = randf_range(-20,20)
offset_x += global_position.x
offset_y += global_position.y
return Vector2(offset_x,offset_y)
func _animate_spawn() -> void:
scale = Vector2.ZERO
var size_scling = create_tween()
size_scling.tween_property(self, "scale", Vector2(1,1),0.4)
var jump = create_tween()
var landing = _get_random_landing_position()
jump.tween_property(self, "global_position:x", landing.x, 0.2).set_ease(Tween.EASE_OUT).set_trans(Tween.TRANS_QUAD)
jump.parallel()
jump.tween_property(self, "global_position:y", global_position.y - 5, 0.2).set_ease(Tween.EASE_OUT).set_trans(Tween.TRANS_QUAD)
jump.tween_property(self, "global_position:y", landing.y, 0.2).set_ease(Tween.EASE_IN).set_trans(Tween.TRANS_QUAD)