GodotComponentTest/Components/ClickableComponent.gd

17 lines
402 B
GDScript

class_name ClickableComponent
extends Node
signal clicked()
export var collision_size = Vector2(1, 1)
onready var collision_shape = $Area2D
# Called when the node enters the scene tree for the first time.
func _ready():
collision_shape.scale = collision_size
func _on_Area2D_input_event(viewport, event, shape_idx):
if event is InputEventMouseButton and event.pressed:
emit_signal ("clicked")