#Help with Implementing a System for Moving and Placing Sprites Based on Mouse Input

1 messages · Page 1 of 1 (latest)

void hatch
#

Bump

fast fossil
#

Someone mentioned an onmousemotion event yesterday, maybe look into that for updating the sprite location only when the button is pressed

void hatch
#

I couldn't find the post you were referring to. I think the issue is that when I press the button and enter the function, the left-click event that was used to press the button also triggers the if condition. As a result, the sprite ends up at the same position where I clicked the button. Should I add a delay in between, like this: func _on_mysticButton_button_down() -> void:
var curr_sprite = Sprite2D.new()
curr_sprite.texture = load("res://assets/mystic.png")
curr_sprite.modulate.a = 0.5
while true:
curr_sprite.position = get_global_mouse_position()
#delay here

    if Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT):
        curr_sprite.modulate.a = 1
        add_child(curr_sprite)
        return
return