mirror of
https://github.com/tonytins/dressupzack
synced 2025-06-26 00:24:44 -04:00
Basic drag and drop functionality
Admittedly, I accidentally followed a far more simpler tutorial, but it works.
This commit is contained in:
parent
8979422160
commit
9b849376ae
45 changed files with 127 additions and 711 deletions
|
@ -1,7 +0,0 @@
|
|||
# This project is licensed under the Artistic-2.0 license.
|
||||
# See the LICENSE file in the project root for more information.
|
||||
extends "res://scripts/clothing/clothing_base.gd"
|
||||
|
||||
func _on_accessory_pressed():
|
||||
GameData.accessory = texture_normal
|
||||
$select.play()
|
|
@ -1,7 +0,0 @@
|
|||
# This project is licensed under the Artistic-2.0 license.
|
||||
# See the LICENSE file in the project root for more information.
|
||||
extends "res://scripts/clothing/clothing_base.gd"
|
||||
|
||||
func _on_bottoms_pressed():
|
||||
GameData.bottom = texture_normal
|
||||
$select.play()
|
37
scripts/clothing/clothing.gd
Normal file
37
scripts/clothing/clothing.gd
Normal file
|
@ -0,0 +1,37 @@
|
|||
# This project is licensed under the Artistic-2.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
|
|
@ -1,6 +0,0 @@
|
|||
# This project is licensed under the Artistic-2.0 license.
|
||||
# See the LICENSE file in the project root for more information.
|
||||
extends TextureButton
|
||||
|
||||
@onready var player = $select
|
||||
@onready var character = preload("res://resources/character.tres")
|
|
@ -1,7 +0,0 @@
|
|||
# This project is licensed under the Artistic-2.0 license.
|
||||
# See the LICENSE file in the project root for more information.
|
||||
extends "res://scripts/clothing/clothing_base.gd"
|
||||
|
||||
func _on_tops_pressed():
|
||||
GameData.top = texture_normal
|
||||
$select.play()
|
|
@ -1,7 +0,0 @@
|
|||
# This project is licensed under the Artistic-2.0 license.
|
||||
# See the LICENSE file in the project root for more information.
|
||||
extends "res://scripts/clothing/clothing_base.gd"
|
||||
|
||||
func _on_undies_pressed():
|
||||
GameData.underwear = texture_normal
|
||||
$select.play()
|
Loading…
Add table
Add a link
Reference in a new issue