Some improvements
This commit is contained in:
parent
0418606bd8
commit
f816a8b886
4 changed files with 81 additions and 17 deletions
|
|
@ -19,13 +19,18 @@ func _ready() -> void:
|
|||
func _gui_input(event: InputEvent) -> void:
|
||||
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and event.pressed:
|
||||
dragged = true
|
||||
var pos = global_position
|
||||
top_level = true
|
||||
global_position = pos
|
||||
accept_event()
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if dragged and event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and not event.pressed:
|
||||
dragged = false
|
||||
|
||||
var pos = global_position
|
||||
top_level = false
|
||||
global_position = pos
|
||||
accept_event()
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
|
|
@ -34,6 +39,6 @@ func _process(_delta: float) -> void:
|
|||
return
|
||||
|
||||
var mouse_pos = get_global_mouse_position()-get_combined_pivot_offset()
|
||||
position = lerp(position,mouse_pos,0.25)
|
||||
var relative_x = mouse_pos.x - position.x
|
||||
global_position = lerp(global_position,mouse_pos,0.25)
|
||||
var relative_x = mouse_pos.x - global_position.x
|
||||
rotation = lerp(rotation,clamp(relative_x/PIXEL_PER_ROTATION*ROTATION,-ROTATION,ROTATION),0.25)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue