From 4e9a94c56f6aea4b361b86a6e226128d4bda8fb6 Mon Sep 17 00:00:00 2001 From: cutekibry Date: Sat, 10 Feb 2024 14:40:33 +0800 Subject: [PATCH] =?UTF-8?q?refactor(card):=20=E5=B0=86=20Highlight=20borde?= =?UTF-8?q?r=20=E7=8B=AC=E7=AB=8B=E5=87=BA=E6=9D=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将原先 card_highlighted.png 替换为仅包含高亮而不包含卡背颜色的素材 card_highlight_border.png, 同时新建 Sprite2D 场景 HighlightSprite 用于显示高亮 --- objects/card/card.gd | 9 ++--- objects/card/card.tscn | 25 ++++++------- objects/card/card_highlight_border.png | Bin 0 -> 183 bytes objects/card/card_highlight_border.png.import | 34 ++++++++++++++++++ objects/card/card_highlighted.png | Bin 187 -> 0 bytes 5 files changed, 49 insertions(+), 19 deletions(-) create mode 100644 objects/card/card_highlight_border.png create mode 100644 objects/card/card_highlight_border.png.import delete mode 100644 objects/card/card_highlighted.png diff --git a/objects/card/card.gd b/objects/card/card.gd index 72b76c1..4e6bcb9 100644 --- a/objects/card/card.gd +++ b/objects/card/card.gd @@ -25,6 +25,7 @@ var is_shaking := false func _ready(): origin_global_position = global_position last_global_position = global_position + $HighlightSprite.visible = false func _on_mouse_release(): #prints(entered_area.name, is_card_entered, entered_area.occupied) @@ -135,22 +136,22 @@ func shake(is_letter_red: bool, amount: float, duration: float) -> void: if is_letter_red: $Word.set_color(ImageLib.PALETTE["red"]) else: - $CardBackSprite.animation = "default" + $HighlightSprite.visible = false + func _on_mouse_entered(): - $CardBackSprite.animation = "highlighted" + $HighlightSprite.visible = true Input.set_default_cursor_shape(Input.CURSOR_POINTING_HAND) func _on_mouse_exited(): - $CardBackSprite.animation = "default" + $HighlightSprite.visible = false Input.set_default_cursor_shape(Input.CURSOR_ARROW) func set_color(value: Color) -> void: $Word.set_color(value) - func set_victory(v: bool): if v: $CollisionShape2D.set_deferred("disabled", true) diff --git a/objects/card/card.tscn b/objects/card/card.tscn index 531bdc5..8f54e54 100644 --- a/objects/card/card.tscn +++ b/objects/card/card.tscn @@ -5,11 +5,9 @@ [ext_resource type="Texture2D" uid="uid://cfbqh1k0etr6g" path="res://objects/card/card1.png" id="3_o4f0v"] [ext_resource type="Texture2D" uid="uid://c8qjbksyn1bqt" path="res://objects/card/card2.png" id="4_c30j1"] [ext_resource type="Texture2D" uid="uid://bevrfq1hhyqwe" path="res://objects/card/card3.png" id="5_w81n3"] -[ext_resource type="Texture2D" uid="uid://cmcc5xrpkrd0f" path="res://objects/card/card_highlighted.png" id="6_po2i6"] +[ext_resource type="Texture2D" uid="uid://pmapbo480in1" path="res://objects/card/card_highlight_border.png" id="7_kix4t"] [ext_resource type="AudioStream" uid="uid://cj4v8ehypq3sk" path="res://objects/card/put_down.wav" id="7_u4ylf"] -[sub_resource type="RectangleShape2D" id="RectangleShape2D_gu6l6"] - [sub_resource type="SpriteFrames" id="SpriteFrames_fo0r0"] animations = [{ "frames": [{ @@ -25,16 +23,10 @@ animations = [{ "loop": true, "name": &"default", "speed": 5.0 -}, { -"frames": [{ -"duration": 1.0, -"texture": ExtResource("6_po2i6") -}], -"loop": true, -"name": &"highlighted", -"speed": 5.0 }] +[sub_resource type="RectangleShape2D" id="RectangleShape2D_gu6l6"] + [node name="Card" type="Area2D"] z_index = 50 script = ExtResource("1_0bviv") @@ -45,14 +37,17 @@ frame_progress = 0.111549 text_id = 1 color = Color(0, 0, 0, 1) -[node name="CollisionShape2D" type="CollisionShape2D" parent="."] -z_index = 15 -shape = SubResource("RectangleShape2D_gu6l6") - [node name="CardBackSprite" type="AnimatedSprite2D" parent="."] sprite_frames = SubResource("SpriteFrames_fo0r0") autoplay = "default" +[node name="HighlightSprite" type="Sprite2D" parent="."] +texture = ExtResource("7_kix4t") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +z_index = 15 +shape = SubResource("RectangleShape2D_gu6l6") + [node name="SFXPutDown" type="AudioStreamPlayer" parent="."] stream = ExtResource("7_u4ylf") volume_db = 13.117 diff --git a/objects/card/card_highlight_border.png b/objects/card/card_highlight_border.png new file mode 100644 index 0000000000000000000000000000000000000000..2f7f1952c44107cca096b4b9fb76f614b8b5c714 GIT binary patch literal 183 zcmeAS@N?(olHy`uVBq!ia0vp^G9b*s1|*Ak?@s|zjKx9jP7LeL$-D$|3O!vMLp(a) zUOULuV8FwC!R^og_;u<_(?SHJt330h7w22+8g%Wpe*c$~;m)<#05;{rKhokSpS`nM zao%BrM{c6WI*(mrw0X+3JMQ@A=W!YV3mh7mSoby0Rn7WxJig2C>-qDWr(Y|Rd$FQ3 gE!fp!+3r{J@1$*v&c*~(04-@lUpr0wzrw;tOG&9pjFZ9Sz1E4Q#Khl) zZ4J4xyIyejILYxatT