garden touch scrolling and animations

This commit is contained in:
BimDav
2024-01-16 15:46:54 +01:00
parent a24609e2c1
commit e32bc8090b
4 changed files with 63 additions and 3 deletions
+20
View File
@@ -53,6 +53,7 @@ func set_flowers(p_flowers: Array[GardenLayout.Flower]) -> void:
flower_control.texture = load(flower_path_model % [flower.color+1, flower.type+1, "Large"])
flower_control.position = flower.position
flower_control.size = flower_control.get_combined_minimum_size() * 3
flower_control.pivot_offset = flower_control.size / 2
func set_lesson_buttons(p_lesson_buttons: Array[GardenLayout.LessonButton]) -> void:
@@ -68,6 +69,7 @@ func set_lesson_buttons(p_lesson_buttons: Array[GardenLayout.LessonButton]) -> v
lesson_button_control.size = lesson_button_control.get_combined_minimum_size() * 3
lesson_button_control.position = Vector2(lesson_button.position) - lesson_button_control.size / 4
lesson_button_control.visible = true
lesson_button_control.pivot_offset = lesson_button_control.size / 2
func set_background(p_color: int) -> void:
@@ -83,3 +85,21 @@ func _ready() -> void:
func set_lesson_label(ind: int, text: String) -> void:
assert(ind < lesson_labels.size())
lesson_labels[ind].text = text
func pop_animation() -> void:
var tween: = create_tween()
tween.set_parallel(true)
for flower_control in flower_controls:
tween.tween_property(flower_control, "scale", Vector2(0, 0), 0.1)
for lesson_button_control in lesson_button_controls:
tween.tween_property(lesson_button_control, "scale", Vector2(0.7, 0.7), 0.1)
await tween.finished
tween = create_tween()
tween.set_parallel(true)
tween.set_ease(Tween.EASE_OUT)
tween.set_trans(Tween.TRANS_BOUNCE)
for flower_control in flower_controls:
tween.tween_property(flower_control, "scale", Vector2(1., 1.), 0.9)
for lesson_button_control in lesson_button_controls:
tween.tween_property(lesson_button_control, "scale", Vector2(1., 1.), 0.9)
+4 -1
View File
@@ -1,4 +1,4 @@
[gd_scene load_steps=7 format=3 uid="uid://mf4fc4l3dkrn"]
[gd_scene load_steps=7 format=3 uid="uid://btg3qd8eld1mm"]
[ext_resource type="Script" path="res://resources/gardens/garden.gd" id="1_5owem"]
[ext_resource type="Script" path="res://resources/gardens/garden_layout.gd" id="2_8g7o4"]
@@ -100,6 +100,7 @@ vertical_alignment = 1
[node name="Button2" type="TextureRect" parent="Buttons"]
unique_name_in_owner = true
visible = false
z_index = 1
layout_mode = 0
offset_left = 500.0
@@ -142,6 +143,7 @@ vertical_alignment = 1
[node name="Button3" type="TextureRect" parent="Buttons"]
unique_name_in_owner = true
visible = false
z_index = 1
layout_mode = 0
offset_left = 500.0
@@ -184,6 +186,7 @@ vertical_alignment = 1
[node name="Button4" type="TextureRect" parent="Buttons"]
unique_name_in_owner = true
visible = false
z_index = 1
layout_mode = 0
offset_left = 500.0