From 68a5b8f305e312c82a32da062cafae419e5f6a29 Mon Sep 17 00:00:00 2001 From: Zacharie Guet Date: Sun, 1 Sep 2024 22:28:18 +0200 Subject: [PATCH] Adding plant animation --- objects/plant.tscn | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/objects/plant.tscn b/objects/plant.tscn index 88abbfd..6118af2 100644 --- a/objects/plant.tscn +++ b/objects/plant.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=6 format=3 uid="uid://x4kv2y5f52cm"] +[gd_scene load_steps=9 format=3 uid="uid://x4kv2y5f52cm"] [ext_resource type="Script" path="res://scripts/plant.gd" id="1_drvq1"] [ext_resource type="Texture2D" uid="uid://b3kjaw1hajc6s" path="res://assets/grille_seeds.png" id="1_n5onq"] @@ -21,6 +21,43 @@ animations = [{ [sub_resource type="CircleShape2D" id="CircleShape2D_jksuk"] radius = 36.0 +[sub_resource type="Animation" id="Animation_3tubk"] +resource_name = "Growing" +length = 0.4 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("AnimatedSprite2D:scale") +tracks/0/interp = 2 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 0.2, 0.4), +"transitions": PackedFloat32Array(1, 1, 1), +"update": 0, +"values": [Vector2(0.1, 0.1), Vector2(0.12, 0.3), Vector2(0.2, 0.2)] +} + +[sub_resource type="Animation" id="Animation_fcus3"] +length = 0.001 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("AnimatedSprite2D:scale") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [Vector2(0.2, 0.2)] +} + +[sub_resource type="AnimationLibrary" id="AnimationLibrary_da8e6"] +_data = { +"Growing": SubResource("Animation_3tubk"), +"RESET": SubResource("Animation_fcus3") +} + [node name="Plant" type="Node2D"] script = ExtResource("1_drvq1") @@ -45,6 +82,11 @@ offset = Vector2(0, -250) [node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"] shape = SubResource("CircleShape2D_jksuk") +[node name="AnimationPlayer" type="AnimationPlayer" parent="."] +libraries = { +"": SubResource("AnimationLibrary_da8e6") +} + [connection signal="timeout" from="Growing" to="." method="_on_growing_timeout"] [connection signal="timeout" from="NeedChecker" to="." method="_on_need_checker_timeout"] [connection signal="timeout" from="SaplingCountDown" to="." method="_on_sapling_count_down_timeout"]