From 349a1bf0d3ec0609ee33a15d9fad9ea536116e50 Mon Sep 17 00:00:00 2001 From: CactiChameleon9 Date: Tue, 26 Jul 2022 09:57:58 +0100 Subject: [PATCH] Add a remove animation and method --- UI/CardView.gd | 9 +++++++++ UI/CardView.tscn | 23 ++++++++++++++++++++--- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/UI/CardView.gd b/UI/CardView.gd index ca594f4..fa570e7 100644 --- a/UI/CardView.gd +++ b/UI/CardView.gd @@ -87,5 +87,14 @@ func card_view_run(): queue_free() +func card_view_remove(): + # play the remove animation + $AnimationPlayer.play("Drop Off") + yield($AnimationPlayer, "animation_finished") + + # remove the card completely once used + queue_free() + + func connect_signals(): card.connect("card_removed", self, "card_view_run") diff --git a/UI/CardView.tscn b/UI/CardView.tscn index 2875d8d..b70d185 100644 --- a/UI/CardView.tscn +++ b/UI/CardView.tscn @@ -1,10 +1,10 @@ -[gd_scene load_steps=10 format=2] +[gd_scene load_steps=11 format=2] [ext_resource path="res://UI/CardView.gd" type="Script" id=1] [ext_resource path="res://Assets/Metropolis-font/Metropolis-Bold.ttf" type="DynamicFontData" id=4] [ext_resource path="res://AutoGridContainer - Full Version/AutoGridContainer.tscn" type="PackedScene" id=6] -[sub_resource type="StyleBoxFlat" id=6] +[sub_resource type="StyleBoxFlat" id=9] bg_color = Color( 0.858824, 0.278431, 0.345098, 1 ) corner_radius_top_left = 20 corner_radius_top_right = 20 @@ -24,6 +24,22 @@ size = 20 use_filter = true font_data = ExtResource( 4 ) +[sub_resource type="Animation" id=10] +resource_name = "Drop Off" +length = 0.5 +tracks/0/type = "value" +tracks/0/path = NodePath("LocalPosition:rect_position") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/keys = { +"times": PoolRealArray( 0, 0.5 ), +"transitions": PoolRealArray( 0.297304, 1 ), +"update": 0, +"values": [ Vector2( 0, 0 ), Vector2( 0, 800 ) ] +} + [sub_resource type="Animation" id=7] resource_name = "Fly Off" length = 0.5 @@ -97,7 +113,7 @@ anchor_bottom = 1.0 unique_name_in_owner = true anchor_right = 1.0 anchor_bottom = 1.0 -custom_styles/panel = SubResource( 6 ) +custom_styles/panel = SubResource( 9 ) [node name="VBox" type="VBoxContainer" parent="LocalPosition"] anchor_right = 1.0 @@ -135,5 +151,6 @@ valign = 1 autowrap = true [node name="AnimationPlayer" type="AnimationPlayer" parent="."] +"anims/Drop Off" = SubResource( 10 ) "anims/Fly Off" = SubResource( 7 ) anims/RESET = SubResource( 8 )