32 lines
538 B
GDScript
32 lines
538 B
GDScript
extends Area2D
|
|
|
|
var ball
|
|
var held_object = null
|
|
|
|
|
|
|
|
|
|
func _on_TextureButton_button_down() -> void:
|
|
ball = load("res://Balls/Ball.tscn").instance()
|
|
ball.position = get_global_mouse_position()
|
|
ball.mode = RigidBody2D.MODE_STATIC
|
|
ball.held = true
|
|
held_object = ball
|
|
add_child(ball)
|
|
|
|
|
|
|
|
|
|
func _on_TextureButton_button_up() -> void:
|
|
held_object.drop(Input.get_last_mouse_speed())
|
|
ball.held = false
|
|
held_object = null
|
|
|
|
|
|
|
|
|
|
func _on_ServeArea_mouse_exited() -> void:
|
|
print("Gone")
|
|
if held_object != null:
|
|
_on_TextureButton_button_up()
|