I'm trying to do a simple drag and drop, that's why, following some samples, I'm using a connection of an Area2D input_event.
I do it in an simple scene to be instanced later in the main scene.
The scene tree:
--Sprite (also tried out: TextureRect and Button)
Then I connect, by nodo tab, the CollisionObject2D.input_event from the Area2D to this function:
func _on_area_input_event( viewport, event, shape_idx ):
dragged = true
dragged = false
After that, I set the _process event true, and in the function:
# dragged = true
# dragged = false
var xoffset = get_node("img").rect_size.x/2
var yoffset = get_node("img").rect_size.y/2
var pos = Vector2(get_global_mouse_position().x-xoffset,
Well, if I play this scene by its own, It works perfectly, I can drag the image and drop it.
Note: As you can see, after nothing worked out, I tried the comment lines, without handling input_event. It works, but if you instance more than one copy, the move togheter at the same time, hahaha!
Then, in the main scene, I instantiate the scene by doing:
var img = load("res://scenes/draggableImage.tscn").instance()
(background is a TextureRect, also tried with Sprite)
It's added and it's visible for me when playing the main scene, other things like printing a string works fine, but it's not processing the inputevent anymore (even tested with print() inside the "onareainput_event" function)
I don't know why is it happening, I'm getting crazy!
Is it a bug? Should I report it?
Also, I have another minor but annoying problem.
When adding multiple instanced (draggableImage) scene into a VBoxContainer, they stack one over the other, instead of being placed one after the other in column shape.