![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | grognard3 |
Hello, I am have set up the following code for a drag and drop interface to move 3 squares around my screen:
var drag
func _on_StaticBody2D_input_event(viewport, event, shape_idx):
if event is InputEventMouseButton:
drag = event.pressed
func _process(delta):
if Input.is_mouse_button_pressed(BUTTON_LEFT) and drag:
position = get_global_mouse_position()
The drag-and-drop is fine, but there are a few major side effects that I haven’t been able to troubleshoot:
-
All my buttons don’t work. Old buttons (prior to the d-n-d coding) and new buttons made after don’t work. If I put a print() command in the on_ready portion of the buttons, it’s fine, but the on_pressed part of the buttons won’t work at all. I assume it’s because the EventMouseButton is being co-opted by the d-n-d interface, but I’m not sure how to correct this.
-
Dragging the squares leaves them on top of some objects, and below others. They are below one of my buttons, and square 2 always flies below square 1 but above square 3. I tried setting the z-index to 1, but that doesn’t seem to change anything. Is there any solution to this?
Thanks so much!
Sorry, I was a little to quick on the submit button - the first issue was actually already resolved. I am still have problems with the dragged items flying below other objects.
grognard3 | 2019-05-27 00:09