From 67143708bcc07304aa82129895dcd72ad398e8c8 Mon Sep 17 00:00:00 2001 From: CactiChameleon9 Date: Mon, 25 Jul 2022 09:11:42 +0100 Subject: [PATCH] Add InputDiceView and disappear animation --- UI/InputDiceView.gd | 9 +++ UI/InputDiceView.tscn | 153 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 162 insertions(+) create mode 100644 UI/InputDiceView.gd create mode 100644 UI/InputDiceView.tscn diff --git a/UI/InputDiceView.gd b/UI/InputDiceView.gd new file mode 100644 index 0000000..8d6c2fb --- /dev/null +++ b/UI/InputDiceView.gd @@ -0,0 +1,9 @@ +tool +extends Control + +func _process(_delta): + + # update the pivot offset to make sure the object's animations + # are always centered + $Sprite.rect_pivot_offset = rect_size/2 + $Particles2D.position = rect_size/2 diff --git a/UI/InputDiceView.tscn b/UI/InputDiceView.tscn new file mode 100644 index 0000000..4c4fe51 --- /dev/null +++ b/UI/InputDiceView.tscn @@ -0,0 +1,153 @@ +[gd_scene load_steps=10 format=2] + +[ext_resource path="res://Assets/Metropolis-font/Metropolis-Medium.ttf" type="DynamicFontData" id=1] +[ext_resource path="res://Assets/DiceInput.png" type="Texture" id=2] +[ext_resource path="res://UI/InputDiceView.gd" type="Script" id=3] + +[sub_resource type="Curve" id=10] +_data = [ Vector2( 0, 0.121591 ), 0.0, 4.0026, 0, 0, Vector2( 1, 0 ), -1.48166, 0.0, 0, 0 ] + +[sub_resource type="CurveTexture" id=11] +curve = SubResource( 10 ) + +[sub_resource type="ParticlesMaterial" id=12] +lifetime_randomness = 0.12 +flag_disable_z = true +direction = Vector3( 0, 0, 0 ) +spread = 180.0 +gravity = Vector3( 0, 0, 0 ) +initial_velocity = 44.59 +orbit_velocity = 0.56 +orbit_velocity_random = 0.48 +linear_accel = -1.37 +radial_accel = -11.78 +scale = 0.01 +scale_curve = SubResource( 11 ) +hue_variation = 0.03 +hue_variation_random = 1.0 + +[sub_resource type="DynamicFont" id=7] +size = 64 +use_filter = true +font_data = ExtResource( 1 ) + +[sub_resource type="Animation" id=8] +resource_name = "Disappear" +length = 0.5 +step = 0.01 +tracks/0/type = "value" +tracks/0/path = NodePath("Sprite:rect_scale") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/keys = { +"times": PoolRealArray( 0, 0.09, 0.11, 0.5 ), +"transitions": PoolRealArray( 0.406125, 0.392292, 2.07053, 3.36359 ), +"update": 0, +"values": [ Vector2( 1, 1 ), Vector2( 1.2, 1.2 ), Vector2( 1.2, 1.2 ), Vector2( 1e-05, 1e-05 ) ] +} +tracks/1/type = "value" +tracks/1/path = NodePath("Sprite:rect_rotation") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/keys = { +"times": PoolRealArray( 0, 0.09, 0.11, 0.5 ), +"transitions": PoolRealArray( 0.406125, 0.392292, 2.92817, 3.36359 ), +"update": 0, +"values": [ 0.0, 55.0, 55.0, -155.0 ] +} +tracks/2/type = "value" +tracks/2/path = NodePath("Particles2D:emitting") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/keys = { +"times": PoolRealArray( 0, 0.5 ), +"transitions": PoolRealArray( 1, 1 ), +"update": 1, +"values": [ false, true ] +} + +[sub_resource type="Animation" id=9] +length = 0.001 +tracks/0/type = "value" +tracks/0/path = NodePath("Sprite:rect_scale") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/keys = { +"times": PoolRealArray( 0 ), +"transitions": PoolRealArray( 1 ), +"update": 0, +"values": [ Vector2( 1, 1 ) ] +} +tracks/1/type = "value" +tracks/1/path = NodePath("Sprite:rect_rotation") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/keys = { +"times": PoolRealArray( 0 ), +"transitions": PoolRealArray( 1 ), +"update": 0, +"values": [ 0.0 ] +} +tracks/2/type = "value" +tracks/2/path = NodePath("Particles2D:emitting") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/keys = { +"times": PoolRealArray( 0 ), +"transitions": PoolRealArray( 1 ), +"update": 0, +"values": [ false ] +} + +[node name="InputDiceView" type="Control"] +anchor_right = 1.0 +anchor_bottom = 1.0 +script = ExtResource( 3 ) + +[node name="Particles2D" type="Particles2D" parent="."] +position = Vector2( 640, 360 ) +scale = Vector2( 5, 5 ) +emitting = false +amount = 6 +lifetime = 0.75 +one_shot = true +speed_scale = 2.0 +process_material = SubResource( 12 ) +texture = ExtResource( 2 ) + +[node name="ExtraInfo" type="Label" parent="."] +anchor_right = 1.0 +anchor_bottom = 1.0 +size_flags_horizontal = 3 +size_flags_vertical = 3 +custom_colors/font_color = Color( 0, 0, 0, 1 ) +custom_fonts/font = SubResource( 7 ) +align = 1 +valign = 1 + +[node name="Sprite" type="TextureRect" parent="."] +anchor_right = 1.0 +anchor_bottom = 1.0 +rect_min_size = Vector2( 75, 75 ) +rect_pivot_offset = Vector2( 640, 360 ) +size_flags_horizontal = 3 +size_flags_vertical = 3 +texture = ExtResource( 2 ) +expand = true +stretch_mode = 6 + +[node name="AnimationPlayer" type="AnimationPlayer" parent="."] +anims/Disappear = SubResource( 8 ) +anims/RESET = SubResource( 9 )