Skip to content

Commit

Permalink
Merge pull request #59 from ligen131/feat-20240217-level-button-fix
Browse files Browse the repository at this point in the history
feat(level_button): 修改按钮大小并添加两位数显示
  • Loading branch information
cutekibry authored Feb 17, 2024
2 parents a1171a8 + 1d741ea commit dfce327
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 12 deletions.
6 changes: 3 additions & 3 deletions levels/base_level/base_level.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ script = ExtResource("1_diojb")
[node name="BackButton" parent="HUDs" instance=ExtResource("2_0egdl")]

[node name="icon" type="AnimatedSprite2D" parent="HUDs/BackButton"]
position = Vector2(8, 8)
position = Vector2(5, 5)
sprite_frames = SubResource("SpriteFrames_yulkh")
animation = &"return"
centered = false
Expand All @@ -72,11 +72,11 @@ horizontal_alignment = 1
vertical_alignment = 1

[node name="ReplayButton" parent="HUDs" instance=ExtResource("2_0egdl")]
offset_left = 440.0
offset_left = 446.0
offset_right = 480.0

[node name="icon" type="AnimatedSprite2D" parent="HUDs/ReplayButton"]
position = Vector2(6, 6)
position = Vector2(3, 3)
sprite_frames = SubResource("SpriteFrames_5hm0m")
animation = &"replay"
centered = false
Expand Down
17 changes: 14 additions & 3 deletions levels/chapter_menu/level_menu/level_button/level_button.gd
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,27 @@ var button_type = 0 # type = 0 表示为选择章节的按钮, type = 1 表示


func set_word(value: String) -> void:
$Word.set_word(value)

if value.length() == 1:
$Word.set_word(value)
$Word.visible = true
$Word1.visible = false
$Word2.visible = false
elif value.length() == 2:
$Word1.set_word(value[0])
$Word2.set_word(value[1])
$Word.visible = false
$Word1.visible = true
$Word2.visible = true
else:
push_error("level button set_word error: ", value)

func init(chapter_id: int, level_id : int, pos : Vector2, type : int) -> void :
chap_id = chapter_id
lvl_id = level_id

var txt
if type == 0:
txt = "I" + str(chapter_id + 1)
txt = str(chapter_id + 1)
else:
txt = str(level_id + 1)
set_word(txt)
Expand Down
16 changes: 11 additions & 5 deletions levels/chapter_menu/level_menu/level_button/level_button.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,17 @@
[ext_resource type="PackedScene" uid="uid://cvx7wowcbfo0r" path="res://objects/word/word.tscn" id="3_js2i2"]

[node name="LevelButton" instance=ExtResource("1_4bgxw")]
offset_right = 40.0
offset_bottom = 40.0
offset_right = 34.0
offset_bottom = 34.0
script = ExtResource("1_wwqfn")

[node name="Word" parent="." index="0" instance=ExtResource("3_js2i2")]
position = Vector2(19, 19)
scale = Vector2(1.5, 1.5)
text_id = 0
position = Vector2(17, 17)

[node name="Word1" parent="." index="2" instance=ExtResource("3_js2i2")]
visible = false
position = Vector2(11, 17)

[node name="Word2" parent="." index="3" instance=ExtResource("3_js2i2")]
visible = false
position = Vector2(23, 17)
2 changes: 1 addition & 1 deletion levels/chapter_menu/level_menu/level_menu.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ script = ExtResource("1_sd65g")
[node name="BackButton" parent="." instance=ExtResource("2_saprs")]

[node name="icon" type="AnimatedSprite2D" parent="BackButton"]
position = Vector2(8, 8)
position = Vector2(5, 5)
sprite_frames = SubResource("SpriteFrames_waq31")
animation = &"return"
centered = false
Expand Down

0 comments on commit dfce327

Please sign in to comment.