mirror of
https://github.com/tonytins/dressupzack
synced 2025-06-25 16:14:43 -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,17 +0,0 @@
|
|||
# This project is licensed under the Artistic-2.0 license.
|
||||
# See the LICENSE file in the project root for more information.
|
||||
extends Node
|
||||
|
||||
var version = "0.0.0"
|
||||
|
||||
const NEWS_API = "https://static.tonybark.com/news/dressup.json"
|
||||
|
||||
var top = null
|
||||
var bottom = null
|
||||
var underwear = null
|
||||
var accessory = null
|
||||
|
||||
enum characters {
|
||||
ZACK,
|
||||
ANTHONY
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
# This project is licensed under the Artistic-2.0 license.
|
||||
# See the LICENSE file in the project root for more information.
|
||||
extends Node
|
||||
|
||||
signal indicate
|
|
@ -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()
|
|
@ -2,22 +2,9 @@
|
|||
# See the LICENSE file in the project root for more information.
|
||||
extends Control
|
||||
|
||||
@export var version: String = "1.0.0"
|
||||
|
||||
@onready var character = preload("res://resources/character.tres")
|
||||
@onready var blank_accessory = preload("res://sprites/clothes/blank_top.png")
|
||||
@onready var base_top = preload("res://sprites/character/character_base_top.svg")
|
||||
@onready var base_bottom = preload("res://sprites/character/character_base_legs.svg")
|
||||
|
||||
@onready var export_btn = $CenterBtns/ButtonCtr/ExportBtn
|
||||
@onready var import_btn = $CenterBtns/ButtonCtr/ImportBtn
|
||||
@onready var http_request = $NewsWin/NewsBtns/HTTPRequest
|
||||
|
||||
func _ready():
|
||||
var version = ProjectSettings.get_setting("application/config/version")
|
||||
var verLabel = $VersionLbl
|
||||
verLabel.text = "v" + version
|
||||
GameData.version = version
|
||||
|
||||
if OS.get_name() == "HTML5":
|
||||
export_btn.disabled = true
|
||||
import_btn.disabled = true
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
# This project is licensed under the Artistic-2.0 license.
|
||||
# See the LICENSE file in the project root for more information.
|
||||
extends TabContainer
|
||||
|
||||
@onready var character = preload("res://resources/character.tres")
|
||||
@onready var blank_accessory = preload("res://sprites/clothes/blank_top.png")
|
||||
@onready var base_top = preload("res://sprites/character/character_base_top.svg")
|
||||
@onready var base_bottom = preload("res://sprites/clothes/owo_censor.svg")
|
||||
|
||||
@onready var pants_grid = $Pants/PantsScroll/PantsGrid
|
||||
@onready var shirts_grid = $Shirts/ShirtsScroll/ShirtsGrid
|
||||
#onready var undies_grid = $Underwear/UndiesScroll/UndiesGrid
|
||||
@onready var accs_grid = $Accessoires/AccsScroll/AccsGrid
|
||||
|
||||
func _on_removeAccessory_pressed():
|
||||
character.accessory = blank_accessory
|
||||
|
||||
func _on_removePants_pressed():
|
||||
character.bottom = base_bottom
|
||||
|
||||
func _on_removeShirt_pressed():
|
||||
character.top = base_top
|
|
@ -1,40 +0,0 @@
|
|||
# This project is licensed under the Artistic-2.0 license.
|
||||
# See the LICENSE file in the project root for more information.
|
||||
extends Node2D
|
||||
|
||||
const _TDU_VERSION = "0.2"
|
||||
const _SAVE_FILE = "user://character.tdu"
|
||||
|
||||
@onready var blank_accessory = preload("res://sprites/clothes/blank_top.png")
|
||||
@onready var base_top = preload("res://sprites/character/character_base_top.svg")
|
||||
@onready var base_bottom = preload("res://sprites/character/character_base_legs.svg")
|
||||
|
||||
@onready var export_win = $Controls/Container/ExportWin
|
||||
@onready var import_win = $Controls/Container/ImportWin
|
||||
|
||||
@onready var accessory = $Body/Accessory
|
||||
#onready var underwear = $Undies
|
||||
@onready var bottom = $Body/Legs
|
||||
@onready var top = $Body/Top
|
||||
# onready var eyes = $Body/Head/Eyes
|
||||
# onready var mouth = $Body/Head/Mouth
|
||||
|
||||
func _process(delta):
|
||||
|
||||
if GameData.accessory != null:
|
||||
accessory.texture = GameData.accessory
|
||||
|
||||
# if GameData.underwear != null:
|
||||
# underwear.texture = GameData.underwear
|
||||
|
||||
if GameData.bottom != null:
|
||||
bottom.texture = GameData.bottom
|
||||
|
||||
if GameData.top != null:
|
||||
top.texture = GameData.top
|
||||
|
||||
func _on_clearBtn_pressed():
|
||||
$Click.play()
|
||||
GameData.accessory = blank_accessory
|
||||
GameData.bottom = base_bottom
|
||||
GameData.top = base_top
|
Loading…
Add table
Add a link
Reference in a new issue