Skip to content

Commit

Permalink
feat: add ui opening animations
Browse files Browse the repository at this point in the history
  • Loading branch information
myin142 committed Aug 19, 2023
1 parent e2bbd00 commit 10ac0f9
Show file tree
Hide file tree
Showing 4 changed files with 225 additions and 13 deletions.
18 changes: 12 additions & 6 deletions godot/src/menu/store/Store.gd
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,27 @@ extends Control
@onready var store_container := $PanelContainer
@onready var anim := $AnimationPlayer

@onready var store_pos = store_container.position

var showing_showcase = false

func _ready():
store_container.hide()
showcase.hide()
anim.play("RESET")

for child in pack_container.get_children():
child.pressed.connect(func(): _unpack_gacha(child))

func _on_store_pressed():
if store_container.visible:
store_container.hide()
showcase.hide()
if anim.is_playing():
return

if store_container.position.y < 0:
anim.play("show_store")
print("show")
else:
store_container.show()
anim.play_backwards("show_store")
print("hide")


func _unpack_gacha(pack: GachaPack):
if GameManager.points.use_points(pack.price):
Expand Down
60 changes: 59 additions & 1 deletion godot/src/menu/store/store.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=9 format=3 uid="uid://djrft25koko4s"]
[gd_scene load_steps=10 format=3 uid="uid://djrft25koko4s"]

[ext_resource type="Script" path="res://src/menu/store/Store.gd" id="1_vq516"]
[ext_resource type="PackedScene" uid="uid://hbh72ag1wvh" path="res://src/menu/store/gacha_pack.tscn" id="2_4wsp4"]
Expand Down Expand Up @@ -44,6 +44,30 @@ tracks/2/keys = {
"update": 0,
"values": [Vector2(1e-05, 1e-05)]
}
tracks/3/type = "value"
tracks/3/imported = false
tracks/3/enabled = true
tracks/3/path = NodePath("PanelContainer:position")
tracks/3/interp = 1
tracks/3/loop_wrap = true
tracks/3/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector2(149, -1500)]
}
tracks/4/type = "value"
tracks/4/imported = false
tracks/4/enabled = true
tracks/4/path = NodePath("PanelContainer:visible")
tracks/4/interp = 1
tracks/4/loop_wrap = true
tracks/4/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [true]
}

[sub_resource type="Animation" id="Animation_anq1q"]
resource_name = "showcase"
Expand Down Expand Up @@ -85,9 +109,38 @@ tracks/2/keys = {
"values": [Vector2(1e-05, 1e-05), Vector2(1, 1)]
}

[sub_resource type="Animation" id="Animation_giphs"]
resource_name = "show_store"
length = 0.5
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("PanelContainer:position")
tracks/0/interp = 2
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.5),
"transitions": PackedFloat32Array(3, 1),
"update": 0,
"values": [Vector2(149, -1500), Vector2(149, 265)]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("PanelContainer:visible")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [true]
}

[sub_resource type="AnimationLibrary" id="AnimationLibrary_y30a3"]
_data = {
"RESET": SubResource("Animation_pkyus"),
"show_store": SubResource("Animation_giphs"),
"showcase": SubResource("Animation_anq1q")
}

Expand All @@ -108,6 +161,10 @@ layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = 149.0
offset_top = -1500.0
offset_right = -149.0
offset_bottom = -2030.0
grow_horizontal = 2
grow_vertical = 2

Expand Down Expand Up @@ -148,6 +205,7 @@ layout_mode = 2
texture_normal = ExtResource("3_eipe8")

[node name="Showcase" type="Control" parent="."]
visible = false
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
Expand Down
13 changes: 10 additions & 3 deletions godot/src/start.gd
Original file line number Diff line number Diff line change
@@ -1,26 +1,33 @@
extends Control

@export var selectables: Control
@export var select_container: Control

@onready var bgm := $BGM
@onready var start_sound := $StartSound

@onready var piece_select := $PieceSelect
@onready var anim := $AnimationPlayer

func _ready():
piece_select.hide()
anim.play("RESET")
GameManager.game_started.connect(_on_game_start)

func _on_game_start():
selectables.close()
create_tween().tween_property(bgm, "volume_db", -50, 1.0).set_trans(Tween.TRANS_CUBIC)
start_sound.play()

func _on_play_pressed():
piece_select.show()
select_container.pivot_offset = select_container.size / 2
anim.play("show_pieces")

func _on_check_energy_timer_timeout():
GameManager.energy.restore()

func _on_start_pressed():
GameManager.start_game()

func _on_piece_select_on_hide():
anim.play_backwards("show_pieces")
await anim.animation_finished
piece_select.hide()
147 changes: 144 additions & 3 deletions godot/src/start.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=19 format=3 uid="uid://qdwfqb2qwrxb"]
[gd_scene load_steps=22 format=3 uid="uid://qdwfqb2qwrxb"]

[ext_resource type="Theme" uid="uid://cvvavdkxk7llv" path="res://theme/theme.tres" id="1_rg8bf"]
[ext_resource type="Script" path="res://src/start.gd" id="2_af8bd"]
Expand Down Expand Up @@ -30,7 +30,130 @@ shader_parameter/background = SubResource("GradientTexture2D_jd218")
[sub_resource type="LabelSettings" id="LabelSettings_pco7m"]
font_size = 72

[node name="Start" type="Control" node_paths=PackedStringArray("selectables")]
[sub_resource type="Animation" id="Animation_20ldf"]
resource_name = "show_pieces"
length = 0.5
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("PieceSelect:visible")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [true]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("PieceSelect/PieceSelect:scale")
tracks/1/interp = 2
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0, 0.5),
"transitions": PackedFloat32Array(3, 3),
"update": 0,
"values": [Vector2(1e-05, 1e-05), Vector2(1, 1)]
}
tracks/2/type = "value"
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/path = NodePath("PieceSelect/Blocker:visible")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/keys = {
"times": PackedFloat32Array(0, 0.4, 0.5),
"transitions": PackedFloat32Array(1, 1, 1),
"update": 1,
"values": [true, true, false]
}
tracks/3/type = "value"
tracks/3/imported = false
tracks/3/enabled = true
tracks/3/path = NodePath("PieceSelect/Selectables:visible")
tracks/3/interp = 1
tracks/3/loop_wrap = true
tracks/3/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [false]
}
tracks/4/type = "method"
tracks/4/imported = false
tracks/4/enabled = true
tracks/4/path = NodePath("PieceSelect/Selectables")
tracks/4/interp = 1
tracks/4/loop_wrap = true
tracks/4/keys = {
"times": PackedFloat32Array(0.5),
"transitions": PackedFloat32Array(1),
"values": [{
"args": [],
"method": &"close"
}]
}

[sub_resource type="Animation" id="Animation_0sthp"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("PieceSelect:visible")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [false]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("PieceSelect/PieceSelect:scale")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector2(1e-05, 1e-05)]
}
tracks/2/type = "value"
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/path = NodePath("PieceSelect/Blocker:visible")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [true]
}
tracks/3/type = "value"
tracks/3/imported = false
tracks/3/enabled = true
tracks/3/path = NodePath("PieceSelect/Selectables:visible")
tracks/3/interp = 1
tracks/3/loop_wrap = true
tracks/3/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [false]
}

[sub_resource type="AnimationLibrary" id="AnimationLibrary_j8rit"]
_data = {
"RESET": SubResource("Animation_0sthp"),
"show_pieces": SubResource("Animation_20ldf")
}

[node name="Start" type="Control" node_paths=PackedStringArray("selectables", "select_container")]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
Expand All @@ -40,6 +163,7 @@ grow_vertical = 2
theme = ExtResource("1_rg8bf")
script = ExtResource("2_af8bd")
selectables = NodePath("PieceSelect/Selectables")
select_container = NodePath("PieceSelect/PieceSelect")

[node name="ColorRect" type="ColorRect" parent="."]
material = SubResource("ShaderMaterial_7ekah")
Expand Down Expand Up @@ -115,7 +239,11 @@ layout_mode = 2
disabled = true
text = "Store"

[node name="Store" parent="." instance=ExtResource("14_6p00d")]
layout_mode = 1

[node name="PieceSelect" type="Control" parent="."]
visible = false
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
Expand All @@ -124,6 +252,7 @@ grow_horizontal = 2
grow_vertical = 2
theme = ExtResource("1_rg8bf")
script = ExtResource("9_qgams")
external = true

[node name="PieceSelect" type="PanelContainer" parent="PieceSelect"]
custom_minimum_size = Vector2(0, 100)
Expand All @@ -137,6 +266,7 @@ offset_top = -50.0
offset_bottom = 50.0
grow_horizontal = 2
grow_vertical = 2
scale = Vector2(1e-05, 1e-05)

[node name="MarginContainer" type="MarginContainer" parent="PieceSelect/PieceSelect"]
layout_mode = 2
Expand Down Expand Up @@ -179,8 +309,13 @@ size_flags_horizontal = 3
size_flags_vertical = 4
alignment = 1

[node name="Store" parent="." instance=ExtResource("14_6p00d")]
[node name="Blocker" type="Control" parent="PieceSelect"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2

[node name="CheckEnergyTimer" type="Timer" parent="."]
autostart = true
Expand All @@ -194,7 +329,13 @@ autoplay = true
stream = ExtResource("8_5k2wf")
volume_db = -15.0

[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
libraries = {
"": SubResource("AnimationLibrary_j8rit")
}

[connection signal="pressed" from="Menu/VBoxContainer/Play" to="." method="_on_play_pressed"]
[connection signal="hidden" from="PieceSelect" to="PieceSelect/Selectables" method="close"]
[connection signal="on_hide" from="PieceSelect" to="." method="_on_piece_select_on_hide"]
[connection signal="pressed" from="PieceSelect/PieceSelect/MarginContainer/VBoxContainer/Start" to="." method="_on_start_pressed"]
[connection signal="timeout" from="CheckEnergyTimer" to="." method="_on_check_energy_timer_timeout"]

0 comments on commit 10ac0f9

Please sign in to comment.