diff --git a/player.gd b/player.gd index 0b9ad75..b3d5e2e 100644 --- a/player.gd +++ b/player.gd @@ -1,12 +1,32 @@ extends CharacterBody2D +@export_group("Skins") +@export var CurrentSkin: CanvasTexture +@export var CurrentHat: CanvasTexture const SPEED = 700.0 +# Change the skin on every sprite +func changeSkin(NewSkin:CanvasTexture,_NewHat:CanvasTexture = null): + CurrentSkin = NewSkin + if (_NewHat): + CurrentHat = _NewHat + + for Sprite :Sprite2D in $Skeleton2D.get_children(): + if (Sprite.has_meta("Type") and Sprite.get_meta("Type") == "Skin"): + Sprite.texture = CurrentSkin + if (Sprite.has_meta("Type") and Sprite.get_meta("Type") == "Hat"): + Sprite.texture = CurrentHat + + + + + func get_input(): var directionX = Input.get_axis("move_left", "move_right") var directionY = Input.get_axis("move_up", "move_down") - # Get the input direction and handle the movement/deceleration. + #region Movement + ## Get the input direction and handle the movement/deceleration. if directionX : velocity.x = directionX * SPEED else: @@ -15,7 +35,7 @@ func get_input(): velocity.y = directionY * SPEED else: velocity.y = move_toward(velocity.y, 0, SPEED) - + #endregion #region Animation if (directionX < 0): $Skeleton2D/root/Hips.set_scale(Vector2(1, 1)) diff --git a/player.tscn b/player.tscn index 6b1eda0..cc4e79d 100644 --- a/player.tscn +++ b/player.tscn @@ -458,9 +458,9 @@ animation = &"Walk" [sub_resource type="AnimationNodeBlendTree" id="AnimationNodeBlendTree_p4347"] graph_offset = Vector2(-455.578, -2.44228) nodes/Animation/node = SubResource("AnimationNodeAnimation_17l2l") -nodes/Animation/position = Vector2(-160, 140) +nodes/Animation/position = Vector2(0, 120) nodes/TimeScale/node = SubResource("AnimationNodeTimeScale_66x5k") -nodes/TimeScale/position = Vector2(60, 120) +nodes/TimeScale/position = Vector2(140, 120) nodes/output/position = Vector2(280, 120) node_connections = [&"TimeScale", 0, &"Animation", &"output", 0, &"TimeScale"] @@ -478,7 +478,6 @@ value_label = "speed" sync = true [sub_resource type="AnimationNodeBlendTree" id="AnimationNodeBlendTree_wgp38"] -graph_offset = Vector2(-55.7817, 106.547) nodes/WalkRun/node = SubResource("AnimationNodeBlendSpace1D_c82tj") nodes/WalkRun/position = Vector2(180, 120) nodes/output/position = Vector2(440, 120) @@ -489,6 +488,8 @@ diffuse_texture = ExtResource("4_ytgpb") [node name="Node2D" type="CharacterBody2D"] script = ExtResource("1_0pgv8") +CurrentSkin = ExtResource("2_45h8h") +CurrentHat = ExtResource("3_qyf3b") [node name="CollisionShape2D" type="CollisionShape2D" parent="."] position = Vector2(0, -75) @@ -513,62 +514,70 @@ playback_default_blend_time = 0.3 [node name="AnimationTree" type="AnimationTree" parent="." groups=["Animation"]] tree_root = SubResource("AnimationNodeBlendTree_wgp38") anim_player = NodePath("../AnimationPlayer") -parameters/WalkRun/blend_position = 624.221 +parameters/WalkRun/blend_position = 178.271 parameters/WalkRun/2/TimeScale/scale = 1.8 [node name="Skeleton2D" type="Skeleton2D" parent="."] position = Vector2(17, 0) [node name="BootL" type="Sprite2D" parent="Skeleton2D"] -position = Vector2(41.976, -40.999) -rotation = -0.525599 -texture = ExtResource("2_45h8h") +position = Vector2(-5.61248, -38.9448) +rotation = 0.142016 region_enabled = true region_rect = Rect2(896, 768, 128, 128) +metadata/Type = "Skin" [node name="BootR" type="Sprite2D" parent="Skeleton2D"] -position = Vector2(-70.9803, -47.9988) -rotation = 0.491578 +position = Vector2(-31.9509, -45.6022) +rotation = -0.232808 +scale = Vector2(1, 1) texture = ExtResource("2_45h8h") region_enabled = true region_rect = Rect2(896, 768, 128, 128) +metadata/Type = "Skin" [node name="Body" type="Sprite2D" parent="Skeleton2D"] -position = Vector2(51, -242.428) +position = Vector2(51, -229.397) texture = ExtResource("2_45h8h") offset = Vector2(-15, 0) region_enabled = true region_rect = Rect2(0, 640, 384, 384) +metadata/Type = "Skin" [node name="HandL" type="Sprite2D" parent="Skeleton2D/Body"] -position = Vector2(-3, 54) +position = Vector2(-20.1603, 51.5819) texture = ExtResource("2_45h8h") region_enabled = true region_rect = Rect2(768, 768, 128, 128) +metadata/Type = "Skin" [node name="HandR" type="Sprite2D" parent="Skeleton2D/Body"] show_behind_parent = true -position = Vector2(-160, 29) +position = Vector2(-154.264, 30.3642) texture = ExtResource("2_45h8h") region_enabled = true region_rect = Rect2(768, 768, 128, 128) +metadata/Type = "Skin" [node name="Tail" type="Sprite2D" parent="Skeleton2D/Body"] show_behind_parent = true -position = Vector2(44, 112.428) -rotation = 0.153589 +position = Vector2(44, 99.3973) +rotation = -0.090184 +scale = Vector2(1, 1) texture = ExtResource("2_45h8h") offset = Vector2(70, 0) region_enabled = true region_rect = Rect2(768, 640, 256, 128) +metadata/Type = "Skin" [node name="Head" type="Sprite2D" parent="Skeleton2D"] -position = Vector2(-40, -415.428) -rotation = 1.31553e-05 +position = Vector2(-40, -402.397) +rotation = 0.0243178 texture = ExtResource("2_45h8h") offset = Vector2(0, -168) region_enabled = true region_rect = Rect2(0, 0, 512, 640) +metadata/Type = "Skin" [node name="Hat" type="Sprite2D" parent="Skeleton2D/Head"] position = Vector2(65, -103) @@ -576,6 +585,7 @@ scale = Vector2(0.6, 0.6) texture = ExtResource("3_qyf3b") region_enabled = true region_rect = Rect2(0, 0, 1152, 1136) +metadata/Type = "Hat" [node name="root" type="Bone2D" parent="Skeleton2D"] position = Vector2(-17, 0) diff --git a/player/currentHat.tres b/player/currentHat.tres index 5a78399..300b70f 100644 --- a/player/currentHat.tres +++ b/player/currentHat.tres @@ -1,6 +1,6 @@ [gd_resource type="CanvasTexture" load_steps=2 format=3 uid="uid://5qixrbrclydr"] -[ext_resource type="Texture2D" uid="uid://0m4sejstlmy7" path="res://extracted/Texture2D/Hat Glasses.png" id="1_ogipp"] +[ext_resource type="Texture2D" uid="uid://hc35pmqglb14" path="res://extracted/Texture2D/Whitch Hat.png" id="1_dwxnm"] [resource] -diffuse_texture = ExtResource("1_ogipp") +diffuse_texture = ExtResource("1_dwxnm")