Add object hit animation
This commit is contained in:
@ -31,6 +31,7 @@ func _process(delta):
|
||||
var hit_object = $body_pivot/raycast.get_collider()
|
||||
if hit_object.type == "resource":
|
||||
inventory[hit_object.resource_type] += 1
|
||||
hit_object.get_node("animation").play("hit")
|
||||
|
||||
#update inventory HUD
|
||||
$hud/inventory/stone_label.text = str(inventory.stone)
|
||||
|
@ -1,6 +1,6 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://ikvaekbnft70"]
|
||||
[gd_scene load_steps=6 format=3 uid="uid://ikvaekbnft70"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://ttb1b3k07qu5" path="res://textures/world/biome/forest/boulder.svg" id="1_474a4"]
|
||||
[ext_resource type="Texture2D" uid="uid://ttb1b3k07qu5" path="res://textures/world/boulder.svg" id="1_wuryf"]
|
||||
|
||||
[sub_resource type="GDScript" id="GDScript_d7f4g"]
|
||||
script/source = "extends StaticBody2D
|
||||
@ -13,13 +13,38 @@ var resource_type = \"stone\"
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_fb1fv"]
|
||||
radius = 64.0
|
||||
|
||||
[sub_resource type="Animation" id="Animation_k7egg"]
|
||||
resource_name = "hit"
|
||||
length = 0.2
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("body:scale")
|
||||
tracks/0/interp = 2
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.1, 0.2),
|
||||
"transitions": PackedFloat32Array(1, 1, 1),
|
||||
"update": 0,
|
||||
"values": [Vector2(0.2, 0.2), Vector2(0.18, 0.18), Vector2(0.2, 0.2)]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_mynaq"]
|
||||
_data = {
|
||||
"hit": SubResource("Animation_k7egg")
|
||||
}
|
||||
|
||||
[node name="stone" type="StaticBody2D"]
|
||||
script = SubResource("GDScript_d7f4g")
|
||||
|
||||
[node name="collision" type="CollisionShape2D" parent="."]
|
||||
visible = false
|
||||
shape = SubResource("CircleShape2D_fb1fv")
|
||||
|
||||
[node name="body" type="Sprite2D" parent="."]
|
||||
scale = Vector2(0.2, 0.2)
|
||||
texture = ExtResource("1_474a4")
|
||||
texture = ExtResource("1_wuryf")
|
||||
|
||||
[node name="animation" type="AnimationPlayer" parent="."]
|
||||
libraries = {
|
||||
"": SubResource("AnimationLibrary_mynaq")
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://c7ir6imnqx4py"]
|
||||
[gd_scene load_steps=6 format=3 uid="uid://c7ir6imnqx4py"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://i7fjjduk8b0c" path="res://textures/world/biome/forest/tree.svg" id="1_nvko3"]
|
||||
|
||||
[sub_resource type="GDScript" id="GDScript_d7f4g"]
|
||||
[sub_resource type="GDScript" id="GDScript_si3d7"]
|
||||
script/source = "extends StaticBody2D
|
||||
|
||||
|
||||
@ -11,10 +11,31 @@ var resource_type = \"wood\"
|
||||
"
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_fb1fv"]
|
||||
radius = 32.0
|
||||
radius = 64.0
|
||||
|
||||
[sub_resource type="Animation" id="Animation_k7egg"]
|
||||
resource_name = "hit"
|
||||
length = 0.2
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("body:scale")
|
||||
tracks/0/interp = 2
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.1, 0.2),
|
||||
"transitions": PackedFloat32Array(1, 1, 1),
|
||||
"update": 0,
|
||||
"values": [Vector2(0.2, 0.2), Vector2(0.18, 0.18), Vector2(0.2, 0.2)]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_mynaq"]
|
||||
_data = {
|
||||
"hit": SubResource("Animation_k7egg")
|
||||
}
|
||||
|
||||
[node name="tree" type="StaticBody2D"]
|
||||
script = SubResource("GDScript_d7f4g")
|
||||
script = SubResource("GDScript_si3d7")
|
||||
|
||||
[node name="collision" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource("CircleShape2D_fb1fv")
|
||||
@ -22,3 +43,8 @@ shape = SubResource("CircleShape2D_fb1fv")
|
||||
[node name="body" type="Sprite2D" parent="."]
|
||||
scale = Vector2(0.2, 0.2)
|
||||
texture = ExtResource("1_nvko3")
|
||||
|
||||
[node name="animation" type="AnimationPlayer" parent="."]
|
||||
libraries = {
|
||||
"": SubResource("AnimationLibrary_mynaq")
|
||||
}
|
||||
|
Reference in New Issue
Block a user