0 votes

I am developing a mobile game, i have a button with a 2d sprite as a child, when the user:
-single tap = it opens a dialog window
-double tap = buys character (not implemente)
-drags = grabs the sprite and moves it with the cursor, if it is relased in the wrong place it goes back to the original positon... the problem is that when, this happenes, it wont let me drag it again, unless I do a single tap first... i have no idea why... the most i have figuered out is that its not detected the "enter focus signal", once the sprite is returned to its original place.

extends TextureButton

#var for activating drag
var drag = false
var focus = false
var placed = false
var original_pos = Vector2(0,0)

#var for characters
onready var char_obj =  preload("res://Scenes/Unit.tscn")

func _ready():
    original_pos = get_node("overlay_cont_0/char_holder_0").position
    pass

func _input(event):
    if event is InputEventScreenDrag:
        #sets dragging on and check to see if the button is the focus
        drag = true
        if focus:
            print("Drag")
            get_node("overlay_cont_0/char_holder_0").position = event.position

func _on_Shop_butt_0_button_down():
    pass

func _on_Shop_butt_0_button_up():
    if !drag:
        get_node("../../../Stats_panel").show()
    drag = false
    focus = false
    if !placed:
        get_node("overlay_cont_0/char_holder_0").position = original_pos

func _on_Shop_butt_0_focus_entered():
    focus = true;
    print("Here")    
asked Feb 26, 2019 in Projects by raffagapro (12 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.