I am trying to detect any event (in this case, a mouse click) on my tile. They look like this :
Tree :
Area2D
- Sprite
- CollisionPolygon2D
- Label
And here is the script, attached to the Area2D :
extends Area2D
func _on_Area2D_input_event( viewport, event, shape_idx ):
if event.type == InputEvent.MOUSE_BUTTON and event.button_index == BUTTON_LEFT and event.pressed:
var label = get_node("Label")
label.set_text("Clicked")
(This is correctly connected, if you wonder)
According to internet... this should work. But this is a tile of a board game, and I instance these tiles by doing :
var tile_scene = load("res://Scenes/hextile.tscn") #tile scene
...
var tile = tile_scene.instance()
...
add_child(tile)
And it seems that instancing these doesn't allow me to change the label of my tiles. I also tested with other similar event, such as mouseenter() and mouseexit(), but with the same result : nothing change.