game: add enemy on-hit animation
This commit is contained in:
@@ -42,6 +42,7 @@ func take_damage(value: float, is_crit: bool = false):
|
||||
var dm = preload("res://scenes/damage_numbers.tscn").instantiate()
|
||||
dm.damage_taken = value
|
||||
dm.critical_damage = is_crit
|
||||
animation_player.play("take_damage")
|
||||
add_child(dm)
|
||||
if health <= 0:
|
||||
die()
|
||||
|
@@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=8 format=3 uid="uid://bn8c0cgecvjxl"]
|
||||
[gd_scene load_steps=9 format=3 uid="uid://bn8c0cgecvjxl"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://5x5wimok8uw2" path="res://assets/sprites/roguelikeChar_transparent.png" id="1_6xk8f"]
|
||||
[ext_resource type="Script" uid="uid://ctigdofipl4q5" path="res://scenes/enemies/enemy.gd" id="1_8e3ao"]
|
||||
@@ -44,6 +44,18 @@ tracks/2/keys = {
|
||||
"update": 0,
|
||||
"values": [Color(1, 1, 1, 1)]
|
||||
}
|
||||
tracks/3/type = "value"
|
||||
tracks/3/imported = false
|
||||
tracks/3/enabled = true
|
||||
tracks/3/path = NodePath("Sprite2D:self_modulate")
|
||||
tracks/3/interp = 1
|
||||
tracks/3/loop_wrap = true
|
||||
tracks/3/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Color(1, 1, 1, 1)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_fcftc"]
|
||||
resource_name = "die"
|
||||
@@ -90,11 +102,28 @@ tracks/0/keys = {
|
||||
"values": [Vector2(0, 0), Vector2(0, -7)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_lu5c6"]
|
||||
resource_name = "take_damage"
|
||||
length = 0.25
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Sprite2D:self_modulate")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.25),
|
||||
"transitions": PackedFloat32Array(0.267943, 0.25),
|
||||
"update": 0,
|
||||
"values": [Color(3, 3, 3, 1), Color(1, 1, 1, 1)]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_38ino"]
|
||||
_data = {
|
||||
&"RESET": SubResource("Animation_38ino"),
|
||||
&"die": SubResource("Animation_fcftc"),
|
||||
&"jump": SubResource("Animation_8e3ao")
|
||||
&"jump": SubResource("Animation_8e3ao"),
|
||||
&"take_damage": SubResource("Animation_lu5c6")
|
||||
}
|
||||
|
||||
[node name="Enemy" type="CharacterBody2D" groups=["damagable", "enemy"]]
|
||||
|
Reference in New Issue
Block a user