From 2a9e824a9e808e0b518ebd10e58b7b3e6dafdc09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerard=20Gasc=C3=B3n?= <52170489+GerardGascon@users.noreply.github.com> Date: Sat, 12 Apr 2025 14:16:06 +0200 Subject: [PATCH] feat: started adding animation behaviour --- assets/animations/dragons/green.tres | 30 ++++++------ assets/outfits/decor.tres | 12 +++++ assets/outfits/dragons.tres | 13 ++++-- assets/outfits/hats.tres | 14 +++--- assets/outfits/shirts.tres | 10 ++-- assets/outfits/shoes.tres | 12 ----- scenes/dragon_editor/dragon_editor.tscn | 7 +-- scenes/dragon_list/dragon_properties.tscn | 2 +- scenes/dragons/dragon_sprite.gd | 52 +++++++++++++++++---- scenes/dragons/dragon_sprite.tscn | 56 ++++++++++------------- scenes/main.tscn | 2 +- src/dragon_outfit.gd | 6 +-- 12 files changed, 123 insertions(+), 93 deletions(-) create mode 100644 assets/outfits/decor.tres delete mode 100644 assets/outfits/shoes.tres diff --git a/assets/animations/dragons/green.tres b/assets/animations/dragons/green.tres index 022863c..dd98657 100644 --- a/assets/animations/dragons/green.tres +++ b/assets/animations/dragons/green.tres @@ -1,61 +1,61 @@ [gd_resource type="SpriteFrames" load_steps=16 format=3 uid="uid://4cm7picl2gvs"] -[ext_resource type="Texture2D" uid="uid://f4c3ib4p7gcy" path="res://assets/sprites/dragons/DP_drac01_Anim.png" id="1_7wf4o"] +[ext_resource type="Texture2D" uid="uid://f4c3ib4p7gcy" path="res://assets/sprites/dragons/DP_drac01_Anim.png" id="1_6pw77"] [sub_resource type="AtlasTexture" id="AtlasTexture_7wf4o"] -atlas = ExtResource("1_7wf4o") +atlas = ExtResource("1_6pw77") region = Rect2(0, 216, 108, 108) [sub_resource type="AtlasTexture" id="AtlasTexture_06adf"] -atlas = ExtResource("1_7wf4o") +atlas = ExtResource("1_6pw77") region = Rect2(108, 216, 108, 108) [sub_resource type="AtlasTexture" id="AtlasTexture_r1nr2"] -atlas = ExtResource("1_7wf4o") +atlas = ExtResource("1_6pw77") region = Rect2(216, 216, 108, 108) [sub_resource type="AtlasTexture" id="AtlasTexture_ob486"] -atlas = ExtResource("1_7wf4o") +atlas = ExtResource("1_6pw77") region = Rect2(324, 216, 108, 108) [sub_resource type="AtlasTexture" id="AtlasTexture_vxc6x"] -atlas = ExtResource("1_7wf4o") +atlas = ExtResource("1_6pw77") region = Rect2(0, 0, 108, 108) [sub_resource type="AtlasTexture" id="AtlasTexture_jbw75"] -atlas = ExtResource("1_7wf4o") +atlas = ExtResource("1_6pw77") region = Rect2(108, 0, 108, 108) [sub_resource type="AtlasTexture" id="AtlasTexture_ei2lw"] -atlas = ExtResource("1_7wf4o") +atlas = ExtResource("1_6pw77") region = Rect2(216, 0, 108, 108) [sub_resource type="AtlasTexture" id="AtlasTexture_q6cr0"] -atlas = ExtResource("1_7wf4o") +atlas = ExtResource("1_6pw77") region = Rect2(324, 0, 108, 108) [sub_resource type="AtlasTexture" id="AtlasTexture_m3lw6"] -atlas = ExtResource("1_7wf4o") +atlas = ExtResource("1_6pw77") region = Rect2(432, 0, 108, 108) [sub_resource type="AtlasTexture" id="AtlasTexture_kdf45"] -atlas = ExtResource("1_7wf4o") +atlas = ExtResource("1_6pw77") region = Rect2(540, 0, 108, 108) [sub_resource type="AtlasTexture" id="AtlasTexture_1w6rw"] -atlas = ExtResource("1_7wf4o") +atlas = ExtResource("1_6pw77") region = Rect2(0, 108, 108, 108) [sub_resource type="AtlasTexture" id="AtlasTexture_80v1m"] -atlas = ExtResource("1_7wf4o") +atlas = ExtResource("1_6pw77") region = Rect2(108, 108, 108, 108) [sub_resource type="AtlasTexture" id="AtlasTexture_nv7os"] -atlas = ExtResource("1_7wf4o") +atlas = ExtResource("1_6pw77") region = Rect2(216, 108, 108, 108) [sub_resource type="AtlasTexture" id="AtlasTexture_ly6pi"] -atlas = ExtResource("1_7wf4o") +atlas = ExtResource("1_6pw77") region = Rect2(324, 108, 108, 108) [resource] diff --git a/assets/outfits/decor.tres b/assets/outfits/decor.tres new file mode 100644 index 0000000..aced588 --- /dev/null +++ b/assets/outfits/decor.tres @@ -0,0 +1,12 @@ +[gd_resource type="Resource" script_class="DragonOutfit" load_steps=5 format=3 uid="uid://ba5684xylts3f"] + +[ext_resource type="SpriteFrames" uid="uid://b52ph2qg7ovgc" path="res://assets/animations/decor/escut.tres" id="1_7gbys"] +[ext_resource type="SpriteFrames" uid="uid://d3q17wrt8ii17" path="res://assets/animations/decor/espasa.tres" id="2_igpcj"] +[ext_resource type="SpriteFrames" uid="uid://cjoufnwxcvvf4" path="res://assets/animations/decor/rosa.tres" id="3_wdoma"] +[ext_resource type="Script" uid="uid://rw26nny160xh" path="res://src/dragon_outfit.gd" id="4_l42ho"] + +[resource] +script = ExtResource("4_l42ho") +allow_null = true +outfits = Array[SpriteFrames]([ExtResource("1_7gbys"), ExtResource("2_igpcj"), ExtResource("3_wdoma")]) +metadata/_custom_type_script = "uid://rw26nny160xh" diff --git a/assets/outfits/dragons.tres b/assets/outfits/dragons.tres index 5cf1c05..681af81 100644 --- a/assets/outfits/dragons.tres +++ b/assets/outfits/dragons.tres @@ -1,12 +1,15 @@ -[gd_resource type="Resource" script_class="DragonOutfit" load_steps=5 format=3 uid="uid://bcs60f2k7h0jc"] +[gd_resource type="Resource" script_class="DragonOutfit" load_steps=8 format=3 uid="uid://bcs60f2k7h0jc"] -[ext_resource type="Texture2D" uid="uid://dl87ffgh2hl68" path="res://assets/sprites/dragons/DragonPet_drac01.png" id="1_3e6qx"] -[ext_resource type="Texture2D" uid="uid://davsy68qknywo" path="res://assets/sprites/dragons/DragonPet_drac02.png" id="2_lvc22"] -[ext_resource type="Texture2D" uid="uid://c4l1h6ecobnsu" path="res://assets/sprites/dragons/DragonPet_drac03.png" id="3_8ji77"] +[ext_resource type="SpriteFrames" uid="uid://1yn652crf484" path="res://assets/animations/dragons/blue.tres" id="1_sxi2r"] +[ext_resource type="SpriteFrames" uid="uid://bdri1wjc6eary" path="res://assets/animations/dragons/gray.tres" id="2_7l1b6"] +[ext_resource type="SpriteFrames" uid="uid://4cm7picl2gvs" path="res://assets/animations/dragons/green.tres" id="3_2i6dq"] +[ext_resource type="SpriteFrames" uid="uid://buvaij5fn2jkk" path="res://assets/animations/dragons/orange.tres" id="4_erkm0"] [ext_resource type="Script" uid="uid://rw26nny160xh" path="res://src/dragon_outfit.gd" id="4_sxi2r"] +[ext_resource type="SpriteFrames" uid="uid://chw5o81g1w8qp" path="res://assets/animations/dragons/pink.tres" id="5_waqaf"] +[ext_resource type="SpriteFrames" uid="uid://dmutxyu7jh3d6" path="res://assets/animations/dragons/purple.tres" id="6_236cy"] [resource] script = ExtResource("4_sxi2r") allow_null = false -outfits = Array[Texture2D]([ExtResource("1_3e6qx"), ExtResource("2_lvc22"), ExtResource("3_8ji77")]) +outfits = Array[SpriteFrames]([ExtResource("1_sxi2r"), ExtResource("2_7l1b6"), ExtResource("3_2i6dq"), ExtResource("4_erkm0"), ExtResource("5_waqaf"), ExtResource("6_236cy")]) metadata/_custom_type_script = "uid://rw26nny160xh" diff --git a/assets/outfits/hats.tres b/assets/outfits/hats.tres index dd7f690..b8e2c47 100644 --- a/assets/outfits/hats.tres +++ b/assets/outfits/hats.tres @@ -1,15 +1,15 @@ [gd_resource type="Resource" script_class="DragonOutfit" load_steps=8 format=3 uid="uid://cnhwn6kfcbjl5"] [ext_resource type="Script" uid="uid://rw26nny160xh" path="res://src/dragon_outfit.gd" id="1_e7uo0"] -[ext_resource type="Texture2D" uid="uid://12fv5nymaljj" path="res://assets/sprites/hats/DragonPet_barret_barretina.png" id="1_jhy4n"] -[ext_resource type="Texture2D" uid="uid://bmw61grwcpoik" path="res://assets/sprites/hats/DragonPet_barret_casc.png" id="2_cmu3h"] -[ext_resource type="Texture2D" uid="uid://dy46ipxh5g5up" path="res://assets/sprites/hats/DragonPet_barret_copa.png" id="3_330df"] -[ext_resource type="Texture2D" uid="uid://ct4ilf6g8fe44" path="res://assets/sprites/hats/DragonPet_barret_corona.png" id="4_7rdvc"] -[ext_resource type="Texture2D" uid="uid://d2jh1mprvmnpk" path="res://assets/sprites/hats/DragonPet_barret_palla.png" id="5_1scq7"] -[ext_resource type="Texture2D" uid="uid://b8pf6op2f51p7" path="res://assets/sprites/hats/DragonPet_barret_princesa.png" id="6_2f5tc"] +[ext_resource type="SpriteFrames" uid="uid://cwxqw54jvqryh" path="res://assets/animations/hats/barretina.tres" id="1_jhy4n"] +[ext_resource type="SpriteFrames" uid="uid://okcrgispsiyh" path="res://assets/animations/hats/casc.tres" id="2_cmu3h"] +[ext_resource type="SpriteFrames" uid="uid://deujtfpb6uodr" path="res://assets/animations/hats/copa.tres" id="3_330df"] +[ext_resource type="SpriteFrames" uid="uid://b86f546ym6u3s" path="res://assets/animations/hats/corona.tres" id="4_7rdvc"] +[ext_resource type="SpriteFrames" uid="uid://b2sdrkuvpqyhl" path="res://assets/animations/hats/palla.tres" id="5_1scq7"] +[ext_resource type="SpriteFrames" uid="uid://c6ai0r87uhj4s" path="res://assets/animations/hats/princesa.tres" id="6_2f5tc"] [resource] script = ExtResource("1_e7uo0") allow_null = true -outfits = Array[Texture2D]([ExtResource("1_jhy4n"), ExtResource("2_cmu3h"), ExtResource("3_330df"), ExtResource("4_7rdvc"), ExtResource("5_1scq7"), ExtResource("6_2f5tc")]) +outfits = Array[SpriteFrames]([ExtResource("1_jhy4n"), ExtResource("2_cmu3h"), ExtResource("3_330df"), ExtResource("4_7rdvc"), ExtResource("5_1scq7"), ExtResource("6_2f5tc")]) metadata/_custom_type_script = "uid://rw26nny160xh" diff --git a/assets/outfits/shirts.tres b/assets/outfits/shirts.tres index f8bee6d..4dfd659 100644 --- a/assets/outfits/shirts.tres +++ b/assets/outfits/shirts.tres @@ -1,13 +1,13 @@ [gd_resource type="Resource" script_class="DragonOutfit" load_steps=6 format=3 uid="uid://etegcak2sphs"] -[ext_resource type="Texture2D" uid="uid://cs0ke244c33t2" path="res://assets/sprites/shirts/DragonPet_roba_armadura.png" id="1_8ueji"] +[ext_resource type="SpriteFrames" uid="uid://b7ojkd0itqcx8" path="res://assets/animations/shirts/armadura.tres" id="1_8ueji"] [ext_resource type="Script" uid="uid://rw26nny160xh" path="res://src/dragon_outfit.gd" id="1_yaxr2"] -[ext_resource type="Texture2D" uid="uid://d13xg46q5a7as" path="res://assets/sprites/shirts/DragonPet_roba_faixa.png" id="2_rue66"] -[ext_resource type="Texture2D" uid="uid://b3xnii6r00hol" path="res://assets/sprites/shirts/DragonPet_roba_traje.png" id="3_rq2qf"] -[ext_resource type="Texture2D" uid="uid://bhfmyrxor0fli" path="res://assets/sprites/shirts/DragonPet_roba_tutu.png" id="4_tgfck"] +[ext_resource type="SpriteFrames" uid="uid://dp47llrsgk3c3" path="res://assets/animations/shirts/faixa.tres" id="2_rue66"] +[ext_resource type="SpriteFrames" uid="uid://csm1127xw2qoh" path="res://assets/animations/shirts/traje.tres" id="3_rq2qf"] +[ext_resource type="SpriteFrames" uid="uid://bbae8y4w7du3j" path="res://assets/animations/shirts/tutu.tres" id="4_tgfck"] [resource] script = ExtResource("1_yaxr2") allow_null = true -outfits = Array[Texture2D]([ExtResource("1_8ueji"), ExtResource("2_rue66"), ExtResource("3_rq2qf"), ExtResource("4_tgfck")]) +outfits = Array[SpriteFrames]([ExtResource("1_8ueji"), ExtResource("2_rue66"), ExtResource("3_rq2qf"), ExtResource("4_tgfck")]) metadata/_custom_type_script = "uid://rw26nny160xh" diff --git a/assets/outfits/shoes.tres b/assets/outfits/shoes.tres deleted file mode 100644 index 64b63c1..0000000 --- a/assets/outfits/shoes.tres +++ /dev/null @@ -1,12 +0,0 @@ -[gd_resource type="Resource" script_class="DragonOutfit" load_steps=5 format=3 uid="uid://ba5684xylts3f"] - -[ext_resource type="Texture2D" uid="uid://onajhbpjtnil" path="res://assets/sprites/decor/DragonPet_acc_escut.png" id="1_5pwyu"] -[ext_resource type="Script" uid="uid://rw26nny160xh" path="res://src/dragon_outfit.gd" id="1_lu1y3"] -[ext_resource type="Texture2D" uid="uid://bkiuuvv4kp1oi" path="res://assets/sprites/decor/DragonPet_acc_espasa.png" id="2_d5wid"] -[ext_resource type="Texture2D" uid="uid://c1b8gp5uf2ehk" path="res://assets/sprites/decor/DragonPet_acc_rosa.png" id="3_yasvr"] - -[resource] -script = ExtResource("1_lu1y3") -allow_null = true -outfits = Array[Texture2D]([ExtResource("1_5pwyu"), ExtResource("2_d5wid"), ExtResource("3_yasvr")]) -metadata/_custom_type_script = "uid://rw26nny160xh" diff --git a/scenes/dragon_editor/dragon_editor.tscn b/scenes/dragon_editor/dragon_editor.tscn index 46e87eb..b7a01c3 100644 --- a/scenes/dragon_editor/dragon_editor.tscn +++ b/scenes/dragon_editor/dragon_editor.tscn @@ -3,9 +3,8 @@ [ext_resource type="Script" uid="uid://bfuos2kgfgber" path="res://scenes/dragon_editor/dragon_editor.gd" id="1_8vkll"] [ext_resource type="Resource" uid="uid://cnhwn6kfcbjl5" path="res://assets/outfits/hats.tres" id="2_vvtct"] [ext_resource type="Resource" uid="uid://etegcak2sphs" path="res://assets/outfits/shirts.tres" id="3_xhgxf"] -[ext_resource type="Resource" uid="uid://ba5684xylts3f" path="res://assets/outfits/shoes.tres" id="4_1ivi1"] +[ext_resource type="Resource" uid="uid://ba5684xylts3f" path="res://assets/outfits/decor.tres" id="4_1ivi1"] [ext_resource type="Resource" uid="uid://bcs60f2k7h0jc" path="res://assets/outfits/dragons.tres" id="5_1ivi1"] -[ext_resource type="Texture2D" uid="uid://dl87ffgh2hl68" path="res://assets/sprites/dragons/DragonPet_drac01.png" id="5_xhgxf"] [ext_resource type="Texture2D" uid="uid://12fv5nymaljj" path="res://assets/sprites/hats/DragonPet_barret_barretina.png" id="6_1ivi1"] [ext_resource type="Texture2D" uid="uid://dceoy4417v83e" path="res://assets/sprites/ui/DP_UI_CharCreation_BG.png" id="6_udwtk"] [ext_resource type="Script" uid="uid://dxl7onk7x6h8b" path="res://src/draggable.gd" id="7_1vw8k"] @@ -17,6 +16,8 @@ [ext_resource type="Texture2D" uid="uid://bdrm1nxydvf5t" path="res://assets/sprites/ui/DP_UI_Label_Big.png" id="12_qppok"] [ext_resource type="StyleBox" uid="uid://bhe580k04w6ve" path="res://assets/styles/style_box_empty.tres" id="14_bh8dj"] +[sub_resource type="CompressedTexture2D" id="CompressedTexture2D_f0h1k"] + [sub_resource type="AtlasTexture" id="AtlasTexture_ofxsr"] atlas = ExtResource("7_qppok") region = Rect2(0, 40, 38, 40) @@ -68,7 +69,7 @@ offset_left = 76.0 offset_top = 120.0 offset_right = 152.0 offset_bottom = 208.0 -texture = ExtResource("5_xhgxf") +texture = SubResource("CompressedTexture2D_f0h1k") [node name="Hat" type="TextureRect" parent="CanvasLayer/Dragon"] layout_mode = 1 diff --git a/scenes/dragon_list/dragon_properties.tscn b/scenes/dragon_list/dragon_properties.tscn index 717aac3..54b32a2 100644 --- a/scenes/dragon_list/dragon_properties.tscn +++ b/scenes/dragon_list/dragon_properties.tscn @@ -5,7 +5,7 @@ [ext_resource type="FontFile" uid="uid://dn8qanm8tctb2" path="res://assets/fonts/Montserrat-Regular.ttf" id="2_s7he7"] [ext_resource type="Resource" uid="uid://cnhwn6kfcbjl5" path="res://assets/outfits/hats.tres" id="2_y33em"] [ext_resource type="Resource" uid="uid://etegcak2sphs" path="res://assets/outfits/shirts.tres" id="3_84ie0"] -[ext_resource type="Resource" uid="uid://ba5684xylts3f" path="res://assets/outfits/shoes.tres" id="4_xvxt0"] +[ext_resource type="Resource" uid="uid://ba5684xylts3f" path="res://assets/outfits/decor.tres" id="4_xvxt0"] [node name="DragonProperties" type="Control" node_paths=PackedStringArray("texture_rect", "name_label", "origin_label")] custom_minimum_size = Vector2(0, 128) diff --git a/scenes/dragons/dragon_sprite.gd b/scenes/dragons/dragon_sprite.gd index 3558087..65cfd10 100644 --- a/scenes/dragons/dragon_sprite.gd +++ b/scenes/dragons/dragon_sprite.gd @@ -2,10 +2,10 @@ extends Node2D class_name DragonSprite -@export var hat: Sprite2D -@export var shirt: Sprite2D -@export var decor: Sprite2D -@export var color: Sprite2D +@export var hat: AnimatedSprite2D +@export var shirt: AnimatedSprite2D +@export var decor: AnimatedSprite2D +@export var color: AnimatedSprite2D @export var hat_outfits: DragonOutfit @export var shirt_outfits: DragonOutfit @@ -14,10 +14,19 @@ class_name DragonSprite func dress(properties: DragonProperties): - self.hat.texture = hat_outfits.get_texture(properties.hat) - self.shirt.texture = shirt_outfits.get_texture(properties.shirt) - self.decor.texture = decor_outfits.get_texture(properties.decor) - self.color.texture = color_outfits.get_texture(properties.color) + _set_dress(hat, hat_outfits.get_texture(properties.hat)) + _set_dress(shirt, shirt_outfits.get_texture(properties.shirt)) + _set_dress(decor, decor_outfits.get_texture(properties.decor)) + _set_dress(color, color_outfits.get_texture(properties.color)) + play_idle() + + +func _set_dress(part: AnimatedSprite2D, dress: SpriteFrames): + if dress == null: + part.visible = false + else: + part.visible = true + part.set_sprite_frames(dress) func walk_left(): @@ -28,3 +37,30 @@ func walk_left(): func walk_right(): $Sprite.scale.x = -1 $DragonBody.scale.x = -1 + + +func _play_animation(animation_name: String, part: AnimatedSprite2D) -> void: + if !part.is_visible(): + return + part.play(animation_name) + + +func play_idle() -> void: + _play_animation("idle", hat) + _play_animation("idle", shirt) + _play_animation("idle", decor) + _play_animation("idle", color) + + +func play_fly() -> void: + _play_animation("fly", hat) + _play_animation("fly", shirt) + _play_animation("fly", decor) + _play_animation("fly", color) + + +func play_walk() -> void: + _play_animation("walk", hat) + _play_animation("walk", shirt) + _play_animation("walk", decor) + _play_animation("walk", color) diff --git a/scenes/dragons/dragon_sprite.tscn b/scenes/dragons/dragon_sprite.tscn index 816248a..59ec97b 100644 --- a/scenes/dragons/dragon_sprite.tscn +++ b/scenes/dragons/dragon_sprite.tscn @@ -1,27 +1,24 @@ -[gd_scene load_steps=12 format=3 uid="uid://baa8gpicw2yg0"] +[gd_scene load_steps=11 format=3 uid="uid://baa8gpicw2yg0"] [ext_resource type="Script" uid="uid://bjiap06gs02j" path="res://scenes/dragons/dragon_sprite.gd" id="1_oaoux"] [ext_resource type="Resource" uid="uid://cnhwn6kfcbjl5" path="res://assets/outfits/hats.tres" id="2_mxc00"] -[ext_resource type="Texture2D" uid="uid://12fv5nymaljj" path="res://assets/sprites/hats/DragonPet_barret_barretina.png" id="3_oaoux"] [ext_resource type="Resource" uid="uid://etegcak2sphs" path="res://assets/outfits/shirts.tres" id="3_umqeb"] -[ext_resource type="Resource" uid="uid://ba5684xylts3f" path="res://assets/outfits/shoes.tres" id="4_7b2ll"] -[ext_resource type="Texture2D" uid="uid://b3xnii6r00hol" path="res://assets/sprites/shirts/DragonPet_roba_traje.png" id="4_oaoux"] -[ext_resource type="Texture2D" uid="uid://c1b8gp5uf2ehk" path="res://assets/sprites/decor/DragonPet_acc_rosa.png" id="5_stf6f"] +[ext_resource type="Resource" uid="uid://ba5684xylts3f" path="res://assets/outfits/decor.tres" id="4_7b2ll"] [ext_resource type="Resource" uid="uid://bcs60f2k7h0jc" path="res://assets/outfits/dragons.tres" id="5_x2k4p"] [ext_resource type="SpriteFrames" uid="uid://4cm7picl2gvs" path="res://assets/animations/dragons/green.tres" id="6_yf7bj"] +[ext_resource type="SpriteFrames" uid="uid://cwxqw54jvqryh" path="res://assets/animations/hats/barretina.tres" id="10_7b2ll"] +[ext_resource type="SpriteFrames" uid="uid://csm1127xw2qoh" path="res://assets/animations/shirts/traje.tres" id="11_x2k4p"] +[ext_resource type="SpriteFrames" uid="uid://cjoufnwxcvvf4" path="res://assets/animations/decor/rosa.tres" id="12_rhebu"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_oaoux"] -size = Vector2(76, 88) - -[sub_resource type="CompressedTexture2D" id="CompressedTexture2D_f0h1k"] -load_path = "res://.godot/imported/DragonPet_drac01.png-225ecd48e88f7c99a74b06cb880c2607.ctex" +size = Vector2(108, 88) [node name="Dragon" type="Node2D" node_paths=PackedStringArray("hat", "shirt", "decor", "color")] script = ExtResource("1_oaoux") -hat = NodePath("Sprite/Hat") -shirt = NodePath("Sprite/Shirt") -decor = NodePath("Sprite/Decor") -color = NodePath("Sprite") +hat = NodePath("Dragon/Hat") +shirt = NodePath("Dragon/Shirt") +decor = NodePath("Dragon/Decor") +color = NodePath("Dragon") hat_outfits = ExtResource("2_mxc00") shirt_outfits = ExtResource("3_umqeb") decor_outfits = ExtResource("4_7b2ll") @@ -30,29 +27,22 @@ color_outfits = ExtResource("5_x2k4p") [node name="Area2D" type="Area2D" parent="."] [node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"] -position = Vector2(38, 44) +position = Vector2(54, 44) shape = SubResource("RectangleShape2D_oaoux") -[node name="Sprite" type="Sprite2D" parent="."] -position = Vector2(38, 44) -texture = SubResource("CompressedTexture2D_f0h1k") - -[node name="Hat" type="Sprite2D" parent="Sprite"] -texture = ExtResource("3_oaoux") - -[node name="Shirt" type="Sprite2D" parent="Sprite"] -texture = ExtResource("4_oaoux") - -[node name="Decor" type="Sprite2D" parent="Sprite"] -texture = ExtResource("5_stf6f") - -[node name="DragonBody" type="AnimatedSprite2D" parent="."] -visible = false -position = Vector2(36, 34) +[node name="Dragon" type="AnimatedSprite2D" parent="."] +position = Vector2(54, 34) sprite_frames = ExtResource("6_yf7bj") -animation = &"idle" -autoplay = "idle" -frame_progress = 0.10072 + +[node name="Hat" type="AnimatedSprite2D" parent="Dragon"] +sprite_frames = ExtResource("10_7b2ll") + +[node name="Shirt" type="AnimatedSprite2D" parent="Dragon"] +sprite_frames = ExtResource("11_x2k4p") + +[node name="Decor" type="AnimatedSprite2D" parent="Dragon"] +sprite_frames = ExtResource("12_rhebu") +animation = &"walk" [connection signal="mouse_entered" from="Area2D" to="." method="_on_area_2d_mouse_entered"] [connection signal="mouse_exited" from="Area2D" to="." method="_on_area_2d_mouse_exited"] diff --git a/scenes/main.tscn b/scenes/main.tscn index a75bad7..668fa9f 100644 --- a/scenes/main.tscn +++ b/scenes/main.tscn @@ -8,7 +8,7 @@ [ext_resource type="Script" uid="uid://cj4l3a6a8ro0r" path="res://scenes/create_button.gd" id="4_tbgi4"] [ext_resource type="Resource" uid="uid://etegcak2sphs" path="res://assets/outfits/shirts.tres" id="5_choun"] [ext_resource type="PackedScene" uid="uid://fut42ruut302" path="res://scenes/dragon_editor/dragon_editor.tscn" id="5_tefeu"] -[ext_resource type="Resource" uid="uid://ba5684xylts3f" path="res://assets/outfits/shoes.tres" id="6_ya4ey"] +[ext_resource type="Resource" uid="uid://ba5684xylts3f" path="res://assets/outfits/decor.tres" id="6_ya4ey"] [ext_resource type="Script" uid="uid://oc6mw86npbii" path="res://scenes/list_button.gd" id="9_choun"] [ext_resource type="PackedScene" uid="uid://tubxrqxjic6r" path="res://scenes/dragon_list/dragon_list.tscn" id="10_ya4ey"] [ext_resource type="Texture2D" uid="uid://bc2lykc3gwykh" path="res://assets/sprites/environment/castle/DP_castle_back.png" id="15_muem4"] diff --git a/src/dragon_outfit.gd b/src/dragon_outfit.gd index 9015ca2..092f480 100644 --- a/src/dragon_outfit.gd +++ b/src/dragon_outfit.gd @@ -3,11 +3,11 @@ class_name DragonOutfit @export var allow_null: bool -@export var outfits: Array[Texture2D] +@export var outfits: Array[SpriteFrames] var index: int = 0 -func _init(outfits: Array[Texture2D] = []): +func _init(outfits: Array[SpriteFrames] = []): self.outfits = outfits @@ -44,7 +44,7 @@ func get_index(texture: Texture2D) -> int: return outfits.find(texture) -func get_texture(index: int) -> Texture2D: +func get_texture(index: int) -> SpriteFrames: if index < 0 or index >= len(outfits): return null