Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复开始按钮动画;完成return和replay按钮UI #24

Merged
merged 7 commits into from
Jan 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion levels/base_level/base_level.gd
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ func init(_chap_id: int, _lvl_id: int) -> void:


func _ready():
$HUDs/BackButton.set_word("<")
$HUDs/BackButton/icon.play("return")
$HUDs/ReplayButton/icon.play("replay")

func _process(_delta):
pass
Expand Down Expand Up @@ -186,3 +187,8 @@ func _on_back_button_pressed():
level_menu.init(chap_id, -1)
get_tree().root.add_child(level_menu)
queue_free()


func _on_replay_button_pressed():
print("TO-DO here to handle replay")
pass
59 changes: 58 additions & 1 deletion levels/base_level/base_level.tscn
Original file line number Diff line number Diff line change
@@ -1,11 +1,51 @@
[gd_scene load_steps=7 format=3 uid="uid://cother2aiigge"]
[gd_scene load_steps=15 format=3 uid="uid://cother2aiigge"]

[ext_resource type="Script" path="res://levels/base_level/base_level.gd" id="1_diojb"]
[ext_resource type="PackedScene" uid="uid://xom5kpqs1rue" path="res://objects/calculator/calculator.tscn" id="1_tpuy7"]
[ext_resource type="PackedScene" uid="uid://bepyyenjtc0p3" path="res://levels/chapter_menu/level_menu/level_button/level_button.tscn" id="2_0egdl"]
[ext_resource type="Texture2D" uid="uid://bxda1ilvqwc6f" path="res://objects/styled_button/return1.png" id="3_4xtpo"]
[ext_resource type="AudioStream" uid="uid://cjhl2qr4mau8g" path="res://levels/base_level/level_clear.wav" id="3_ou3kh"]
[ext_resource type="FontFile" uid="uid://1000owdyvwfg" path="res://fonts/unifont-15.1.04.otf" id="3_q0kqv"]
[ext_resource type="Texture2D" uid="uid://cyl7cqhs4xnux" path="res://objects/styled_button/return2.png" id="4_sctgt"]
[ext_resource type="AudioStream" uid="uid://c6rflw11edxrt" path="res://levels/base_level/wrong_answer.wav" id="4_yxsxp"]
[ext_resource type="Texture2D" uid="uid://b48fn2ikxq33d" path="res://objects/styled_button/return3.png" id="5_u8ht0"]
[ext_resource type="Texture2D" uid="uid://cuyseoi8y3567" path="res://objects/styled_button/replay1.png" id="7_xfna7"]
[ext_resource type="Texture2D" uid="uid://dhjiokm51casd" path="res://objects/styled_button/replay2.png" id="8_60asn"]
[ext_resource type="Texture2D" uid="uid://btyxqeveaeh6h" path="res://objects/styled_button/replay3.png" id="9_gpaci"]

[sub_resource type="SpriteFrames" id="SpriteFrames_yulkh"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": ExtResource("3_4xtpo")
}, {
"duration": 1.0,
"texture": ExtResource("4_sctgt")
}, {
"duration": 1.0,
"texture": ExtResource("5_u8ht0")
}],
"loop": true,
"name": &"return",
"speed": 5.0
}]

[sub_resource type="SpriteFrames" id="SpriteFrames_5hm0m"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": ExtResource("7_xfna7")
}, {
"duration": 1.0,
"texture": ExtResource("8_60asn")
}, {
"duration": 1.0,
"texture": ExtResource("9_gpaci")
}],
"loop": true,
"name": &"replay",
"speed": 5.0
}]

[node name="BaseLevel" type="Node"]
script = ExtResource("1_diojb")
Expand All @@ -14,6 +54,12 @@ 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)
sprite_frames = SubResource("SpriteFrames_yulkh")
animation = &"return"
centered = false

[node name="Title" type="Label" parent="HUDs"]
offset_top = 8.0
offset_right = 480.0
Expand All @@ -23,6 +69,16 @@ text = "Title"
horizontal_alignment = 1
vertical_alignment = 1

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

[node name="icon" type="AnimatedSprite2D" parent="HUDs/ReplayButton"]
position = Vector2(6, 6)
sprite_frames = SubResource("SpriteFrames_5hm0m")
animation = &"replay"
centered = false

[node name="Calculator" parent="." instance=ExtResource("1_tpuy7")]

[node name="Cards" type="Node" parent="."]
Expand All @@ -41,3 +97,4 @@ stream = ExtResource("4_yxsxp")
volume_db = 1.0

[connection signal="pressed" from="HUDs/BackButton" to="." method="_on_back_button_pressed"]
[connection signal="pressed" from="HUDs/ReplayButton" to="." method="_on_replay_button_pressed"]
1 change: 0 additions & 1 deletion levels/chapter_menu/chapter_menu.gd
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const button_width : int = 50
const button_heigth : int = 50

func init() -> void:
print("1")
var chap_num : int = len(BaseLevel.instantiate().DATA)
for chapter_id in range(0, chap_num):
# print(chapter_id)
Expand Down
3 changes: 2 additions & 1 deletion levels/chapter_menu/level_menu/level_menu.gd
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func init(chap_id : int, lvl_num : int) -> void:

if lvl_num == -1:
lvl_num = len(BaseLevel.instantiate().DATA[chap_id])

$Title.set_text("Ch." + str(chap_id + 1) + " " + CHAP_NAMES[chap_id])

chapter_id = chap_id
Expand All @@ -34,6 +34,7 @@ func init(chap_id : int, lvl_num : int) -> void:
add_child(button)

func _ready():
$BackButton/icon.play("return")
#print(BaseLevel.instantiate().DATA[chapter_id])
#var level_num : int = len(BaseLevel.instantiate().DATA[chapter_id])
#print(level_num)
Expand Down
28 changes: 27 additions & 1 deletion levels/chapter_menu/level_menu/level_menu.tscn
Original file line number Diff line number Diff line change
@@ -1,14 +1,40 @@
[gd_scene load_steps=4 format=3 uid="uid://doirpa1bwbjhr"]
[gd_scene load_steps=8 format=3 uid="uid://doirpa1bwbjhr"]

[ext_resource type="Script" path="res://levels/chapter_menu/level_menu/level_menu.gd" id="1_sd65g"]
[ext_resource type="PackedScene" uid="uid://bepyyenjtc0p3" path="res://levels/chapter_menu/level_menu/level_button/level_button.tscn" id="2_saprs"]
[ext_resource type="Texture2D" uid="uid://bxda1ilvqwc6f" path="res://objects/styled_button/return1.png" id="3_6x831"]
[ext_resource type="FontFile" uid="uid://1000owdyvwfg" path="res://fonts/unifont-15.1.04.otf" id="3_jlnpm"]
[ext_resource type="Texture2D" uid="uid://cyl7cqhs4xnux" path="res://objects/styled_button/return2.png" id="4_wd0qw"]
[ext_resource type="Texture2D" uid="uid://b48fn2ikxq33d" path="res://objects/styled_button/return3.png" id="5_eexmd"]

[sub_resource type="SpriteFrames" id="SpriteFrames_waq31"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": ExtResource("3_6x831")
}, {
"duration": 1.0,
"texture": ExtResource("4_wd0qw")
}, {
"duration": 1.0,
"texture": ExtResource("5_eexmd")
}],
"loop": true,
"name": &"return",
"speed": 5.0
}]

[node name="LevelMenu" type="Node2D"]
script = ExtResource("1_sd65g")

[node name="BackButton" parent="." instance=ExtResource("2_saprs")]

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

[node name="Title" type="Label" parent="."]
offset_top = 8.0
offset_right = 480.0
Expand Down
3 changes: 1 addition & 2 deletions objects/main_menu/main_menu.gd
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var ChapterMenu = preload("res://levels/chapter_menu/chapter_menu.tscn")

# Called when the node enters the scene tree for the first time.
func _ready():
$start_button/AnimatedSprite2D.play()
play("init")
pass # Replace with function body.

Expand All @@ -12,8 +13,6 @@ func _ready():
func _process(delta):
pass



func _on_animation_finished():
play("wait_for_start")

Expand Down
Loading