mirror of
https://github.com/tonytins/dressupzack
synced 2025-12-18 12:54:43 -05:00
Advanced drag and drop
More precise drag and drop. Still has a few bugs, but most of the base is there. - Removed translations. - Cleaned up README
This commit is contained in:
parent
805cbe2738
commit
2bc37e1100
18 changed files with 173 additions and 58 deletions
37
scripts/clothing.gd
Normal file
37
scripts/clothing.gd
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
# This project is licensed under the GPL-3.0 license.
|
||||
# See the LICENSE file in the project root for more information.
|
||||
extends TextureRect
|
||||
|
||||
var is_draggable = false
|
||||
var is_inside_draggable = false
|
||||
var body_ref
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
if is_draggable:
|
||||
if Input.is_action_just_pressed("click"):
|
||||
global_position = get_global_mouse_position()
|
||||
elif Input.is_action_just_released("click"):
|
||||
is_draggable = false
|
||||
var tween = get_tree().create_tween()
|
||||
if is_inside_draggable:
|
||||
tween.tween_property(self,"postion",body_ref.position,0.2).set_ease(Tween.EASE_OUT)
|
||||
else:
|
||||
tween.tween_property(self,"global_postion",body_ref.position,0.2).set_ease(Tween.EASE_OUT)
|
||||
|
||||
func _get_drag_data(at_position):
|
||||
var preview_texture = TextureRect.new()
|
||||
|
||||
preview_texture.texture = texture
|
||||
preview_texture.expand_mode = 1
|
||||
preview_texture.size = Vector2(106, 112)
|
||||
|
||||
set_drag_preview(preview_texture)
|
||||
|
||||
return preview_texture.texture
|
||||
|
||||
func _can_drop_data(at_position, data):
|
||||
return data is Texture2D
|
||||
|
||||
func _drop_data(at_position, data):
|
||||
texture = data
|
||||
Loading…
Add table
Add a link
Reference in a new issue