Last active
October 17, 2021 00:59
-
-
Save Cowa/fa28abdb1c5e5040dd7cdf99e882bbba to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extends Control | |
var pressed = false | |
var offset = Vector2() | |
####### | |
func _gui_input(event): | |
if Input.is_action_just_pressed("left_click") and is_mouse_on_title(): | |
pressed = true | |
offset = compute_offset() | |
elif Input.is_action_just_released("left_click"): | |
pressed = false | |
elif pressed and event is InputEventMouseMotion: | |
set_position(get_global_mouse_position() + offset) | |
####### | |
func is_mouse_on_title(): | |
return $Title.get_global_rect().has_point(get_global_mouse_position()) | |
func compute_offset(): | |
return $Title.get_global_position() - get_global_mouse_position() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Scene structure: