From 8382919fd11152a25f37a9f9bf687a8e771abed5 Mon Sep 17 00:00:00 2001 From: Matteo Balugani Date: Sun, 1 Oct 2023 23:27:05 +0200 Subject: [PATCH] added animation for copper converter --- convertors/copper_to_silver.gd | 10 ++- convertors/copper_to_silver.tscn | 65 +++++++++++++++++-- default_bus_layout.tres | 8 +++ entity/coin_silver.tscn | 1 - .../copper_converter_front_1.png | 0 .../copper_converter_front_1.png.import | 8 +-- .../copper_converter_front_2.png | 0 .../copper_converter_front_2.png.import | 8 +-- .../copper_converter_front_3.png | 0 .../copper_converter_front_3.png.import | 8 +-- .../copper_converter_front_4.png | 0 .../copper_converter_front_4.png.import | 8 +-- 12 files changed, 91 insertions(+), 25 deletions(-) create mode 100644 default_bus_layout.tres rename entity/{ => copper_to_silver}/copper_converter_front_1.png (100%) rename entity/{ => copper_to_silver}/copper_converter_front_1.png.import (71%) rename entity/{ => copper_to_silver}/copper_converter_front_2.png (100%) rename entity/{ => copper_to_silver}/copper_converter_front_2.png.import (71%) rename entity/{ => copper_to_silver}/copper_converter_front_3.png (100%) rename entity/{ => copper_to_silver}/copper_converter_front_3.png.import (71%) rename entity/{ => copper_to_silver}/copper_converter_front_4.png (100%) rename entity/{ => copper_to_silver}/copper_converter_front_4.png.import (71%) diff --git a/convertors/copper_to_silver.gd b/convertors/copper_to_silver.gd index 6a4189d..a2d7919 100644 --- a/convertors/copper_to_silver.gd +++ b/convertors/copper_to_silver.gd @@ -2,11 +2,15 @@ extends StaticBody2D @export var scene: PackedScene +@onready var _animated_sprite = $AnimatedSprite2D + func _on_collector_collected(body): body.queue_free() - func _on_collector_goal(): - print("silver") + $AnimatedSprite2D.play() + $Timer.start() + +func _on_timer_timeout(): + $AnimatedSprite2D.stop() $Spawner.spawn() - diff --git a/convertors/copper_to_silver.tscn b/convertors/copper_to_silver.tscn index 26f54ed..6019fda 100644 --- a/convertors/copper_to_silver.tscn +++ b/convertors/copper_to_silver.tscn @@ -1,10 +1,52 @@ -[gd_scene load_steps=10 format=3 uid="uid://ratkps4plkhl"] +[gd_scene load_steps=19 format=3 uid="uid://ratkps4plkhl"] [ext_resource type="Script" path="res://convertors/copper_to_silver.gd" id="1_jjv83"] [ext_resource type="PackedScene" uid="uid://dme22vvfgme5f" path="res://entity/coin_silver.tscn" id="2_orv64"] -[ext_resource type="Texture2D" uid="uid://b0uefih0ccwp3" path="res://entity/copper_converter_front_1.png" id="2_vm6by"] [ext_resource type="PackedScene" uid="uid://c5w3b55aiui6c" path="res://collector/collector.tscn" id="3_a4naa"] +[ext_resource type="Texture2D" uid="uid://dq5aowbt2wxec" path="res://entity/copper_to_silver/copper_converter_front_1.png" id="4_04v4v"] [ext_resource type="PackedScene" uid="uid://c67lfbk4gf1ga" path="res://spawner/spawner.tscn" id="5_1n0vw"] +[ext_resource type="Texture2D" uid="uid://ck254fewe4l41" path="res://entity/copper_to_silver/copper_converter_front_2.png" id="5_tbfff"] +[ext_resource type="Texture2D" uid="uid://dg4qq1pgojk8d" path="res://entity/copper_to_silver/copper_converter_front_3.png" id="6_8ghce"] +[ext_resource type="Texture2D" uid="uid://60502lbpup6" path="res://entity/copper_to_silver/copper_converter_front_4.png" id="7_e53sb"] + +[sub_resource type="CompressedTexture2D" id="CompressedTexture2D_5cf2i"] +load_path = "res://.godot/imported/copper_converter_front_1.png-4a922506c789b120b43bf92ad029b601.ctex" + +[sub_resource type="AtlasTexture" id="AtlasTexture_62dyi"] +atlas = ExtResource("4_04v4v") +region = Rect2(0, 2, 32, 33) + +[sub_resource type="AtlasTexture" id="AtlasTexture_gs3wo"] +atlas = ExtResource("5_tbfff") +region = Rect2(0, 2, 32, 33) + +[sub_resource type="AtlasTexture" id="AtlasTexture_tboq2"] +atlas = ExtResource("6_8ghce") +region = Rect2(0, 2, 32, 33) + +[sub_resource type="AtlasTexture" id="AtlasTexture_okgf4"] +atlas = ExtResource("7_e53sb") +region = Rect2(0, 2, 32, 33) + +[sub_resource type="SpriteFrames" id="SpriteFrames_4m3dg"] +animations = [{ +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_62dyi") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_gs3wo") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_tboq2") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_okgf4") +}], +"loop": true, +"name": &"default", +"speed": 5.0 +}] [sub_resource type="RectangleShape2D" id="RectangleShape2D_k11if"] size = Vector2(26, 5) @@ -19,18 +61,23 @@ size = Vector2(3, 28) size = Vector2(25.8333, 5) [node name="CopperToSilver" type="StaticBody2D"] -scale = Vector2(3, 3) script = ExtResource("1_jjv83") scene = ExtResource("2_orv64") [node name="CopperConverterFront1" type="Sprite2D" parent="."] +visible = false texture_filter = 1 -texture = ExtResource("2_vm6by") +texture = SubResource("CompressedTexture2D_5cf2i") + +[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] +texture_filter = 1 +sprite_frames = SubResource("SpriteFrames_4m3dg") +frame_progress = 0.225994 [node name="Collector" parent="." instance=ExtResource("3_a4naa")] collecting_types = Array[StringName]([&"Copper"]) collecting_collision_mask = 4 -collecting_amount = 10 +collecting_amount = 1 [node name="CollisionShape2D" type="CollisionShape2D" parent="Collector"] position = Vector2(0, 9.5) @@ -52,7 +99,15 @@ shape = SubResource("RectangleShape2D_eqmlo") [node name="CollisionShape2D3" type="CollisionShape2D" parent="."] position = Vector2(0, 12.3333) +rotation = 3.14159 shape = SubResource("RectangleShape2D_31dtl") +one_way_collision = true +one_way_collision_margin = 8.0 + +[node name="Timer" type="Timer" parent="."] +wait_time = 1.998 +one_shot = true [connection signal="collected" from="Collector" to="." method="_on_collector_collected"] [connection signal="goal" from="Collector" to="." method="_on_collector_goal"] +[connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"] diff --git a/default_bus_layout.tres b/default_bus_layout.tres new file mode 100644 index 0000000..c0e0387 --- /dev/null +++ b/default_bus_layout.tres @@ -0,0 +1,8 @@ +[gd_resource type="AudioBusLayout" load_steps=2 format=3 uid="uid://b2edg3n5pyluh"] + +[sub_resource type="AudioEffectAmplify" id="AudioEffectAmplify_l4qbw"] +resource_name = "Amplify" + +[resource] +bus/0/effect/0/effect = SubResource("AudioEffectAmplify_l4qbw") +bus/0/effect/0/enabled = false diff --git a/entity/coin_silver.tscn b/entity/coin_silver.tscn index 74ae7ed..f5ec7b0 100644 --- a/entity/coin_silver.tscn +++ b/entity/coin_silver.tscn @@ -19,7 +19,6 @@ linear_damp = 0.1 angular_damp = 0.1 [node name="CollisionShape2D" type="CollisionShape2D" parent="."] -scale = Vector2(2, 2) shape = SubResource("RectangleShape2D_c6byl") [node name="Sprite" type="Sprite2D" parent="CollisionShape2D"] diff --git a/entity/copper_converter_front_1.png b/entity/copper_to_silver/copper_converter_front_1.png similarity index 100% rename from entity/copper_converter_front_1.png rename to entity/copper_to_silver/copper_converter_front_1.png diff --git a/entity/copper_converter_front_1.png.import b/entity/copper_to_silver/copper_converter_front_1.png.import similarity index 71% rename from entity/copper_converter_front_1.png.import rename to entity/copper_to_silver/copper_converter_front_1.png.import index 6bb2195..133e808 100644 --- a/entity/copper_converter_front_1.png.import +++ b/entity/copper_to_silver/copper_converter_front_1.png.import @@ -2,16 +2,16 @@ importer="texture" type="CompressedTexture2D" -uid="uid://b0uefih0ccwp3" -path="res://.godot/imported/copper_converter_front_1.png-4a922506c789b120b43bf92ad029b601.ctex" +uid="uid://dq5aowbt2wxec" +path="res://.godot/imported/copper_converter_front_1.png-a66e383124c5d7a3b9eb25fbca72295e.ctex" metadata={ "vram_texture": false } [deps] -source_file="res://entity/copper_converter_front_1.png" -dest_files=["res://.godot/imported/copper_converter_front_1.png-4a922506c789b120b43bf92ad029b601.ctex"] +source_file="res://entity/copper_to_silver/copper_converter_front_1.png" +dest_files=["res://.godot/imported/copper_converter_front_1.png-a66e383124c5d7a3b9eb25fbca72295e.ctex"] [params] diff --git a/entity/copper_converter_front_2.png b/entity/copper_to_silver/copper_converter_front_2.png similarity index 100% rename from entity/copper_converter_front_2.png rename to entity/copper_to_silver/copper_converter_front_2.png diff --git a/entity/copper_converter_front_2.png.import b/entity/copper_to_silver/copper_converter_front_2.png.import similarity index 71% rename from entity/copper_converter_front_2.png.import rename to entity/copper_to_silver/copper_converter_front_2.png.import index 71c146f..b86e765 100644 --- a/entity/copper_converter_front_2.png.import +++ b/entity/copper_to_silver/copper_converter_front_2.png.import @@ -2,16 +2,16 @@ importer="texture" type="CompressedTexture2D" -uid="uid://dejli5qv8w4wk" -path="res://.godot/imported/copper_converter_front_2.png-ad6be975b80b2675f665f38d953da271.ctex" +uid="uid://ck254fewe4l41" +path="res://.godot/imported/copper_converter_front_2.png-1979402e2a27fcfa511130668aff26e5.ctex" metadata={ "vram_texture": false } [deps] -source_file="res://entity/copper_converter_front_2.png" -dest_files=["res://.godot/imported/copper_converter_front_2.png-ad6be975b80b2675f665f38d953da271.ctex"] +source_file="res://entity/copper_to_silver/copper_converter_front_2.png" +dest_files=["res://.godot/imported/copper_converter_front_2.png-1979402e2a27fcfa511130668aff26e5.ctex"] [params] diff --git a/entity/copper_converter_front_3.png b/entity/copper_to_silver/copper_converter_front_3.png similarity index 100% rename from entity/copper_converter_front_3.png rename to entity/copper_to_silver/copper_converter_front_3.png diff --git a/entity/copper_converter_front_3.png.import b/entity/copper_to_silver/copper_converter_front_3.png.import similarity index 71% rename from entity/copper_converter_front_3.png.import rename to entity/copper_to_silver/copper_converter_front_3.png.import index d15ddf5..c64d384 100644 --- a/entity/copper_converter_front_3.png.import +++ b/entity/copper_to_silver/copper_converter_front_3.png.import @@ -2,16 +2,16 @@ importer="texture" type="CompressedTexture2D" -uid="uid://cj5di48de0ua0" -path="res://.godot/imported/copper_converter_front_3.png-d70c1e7afbe0bf8e25a8058d0feed406.ctex" +uid="uid://dg4qq1pgojk8d" +path="res://.godot/imported/copper_converter_front_3.png-b5633cd8b2b9353cf9b41b07df79cc44.ctex" metadata={ "vram_texture": false } [deps] -source_file="res://entity/copper_converter_front_3.png" -dest_files=["res://.godot/imported/copper_converter_front_3.png-d70c1e7afbe0bf8e25a8058d0feed406.ctex"] +source_file="res://entity/copper_to_silver/copper_converter_front_3.png" +dest_files=["res://.godot/imported/copper_converter_front_3.png-b5633cd8b2b9353cf9b41b07df79cc44.ctex"] [params] diff --git a/entity/copper_converter_front_4.png b/entity/copper_to_silver/copper_converter_front_4.png similarity index 100% rename from entity/copper_converter_front_4.png rename to entity/copper_to_silver/copper_converter_front_4.png diff --git a/entity/copper_converter_front_4.png.import b/entity/copper_to_silver/copper_converter_front_4.png.import similarity index 71% rename from entity/copper_converter_front_4.png.import rename to entity/copper_to_silver/copper_converter_front_4.png.import index ffe6cd7..d4a2fd6 100644 --- a/entity/copper_converter_front_4.png.import +++ b/entity/copper_to_silver/copper_converter_front_4.png.import @@ -2,16 +2,16 @@ importer="texture" type="CompressedTexture2D" -uid="uid://su0uwlynw8x2" -path="res://.godot/imported/copper_converter_front_4.png-9dd5af8e43a7b7232f0bd757b86bd9c1.ctex" +uid="uid://60502lbpup6" +path="res://.godot/imported/copper_converter_front_4.png-3e5661e50d79ebd32965daca68902adc.ctex" metadata={ "vram_texture": false } [deps] -source_file="res://entity/copper_converter_front_4.png" -dest_files=["res://.godot/imported/copper_converter_front_4.png-9dd5af8e43a7b7232f0bd757b86bd9c1.ctex"] +source_file="res://entity/copper_to_silver/copper_converter_front_4.png" +dest_files=["res://.godot/imported/copper_converter_front_4.png-3e5661e50d79ebd32965daca68902adc.ctex"] [params]