fix: combat animation fix; add the death animation + delay;
This commit is contained in:
+12
-2
@@ -18,6 +18,9 @@ func _ready() -> void:
|
|||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
func _physics_process(delta: float) -> void:
|
func _physics_process(delta: float) -> void:
|
||||||
|
if SceneManager.player_hp <= 0:
|
||||||
|
return
|
||||||
|
|
||||||
if not is_attacking:
|
if not is_attacking:
|
||||||
move_player()
|
move_player()
|
||||||
push_blocks()
|
push_blocks()
|
||||||
@@ -78,8 +81,8 @@ func _on_hit_box_area_2d_body_entered(body: Node2D) -> void:
|
|||||||
velocity += normalize_knockback * 500
|
velocity += normalize_knockback * 500
|
||||||
|
|
||||||
func die():
|
func die():
|
||||||
get_tree().call_deferred("reload_current_scene")
|
$AnimatedSprite2D.play("death")
|
||||||
SceneManager.player_hp = 3
|
$DeathTimer.start()
|
||||||
|
|
||||||
func _on_sword_area_2d_body_entered(body: Node2D) -> void:
|
func _on_sword_area_2d_body_entered(body: Node2D) -> void:
|
||||||
var distance_to_enemy: Vector2 = body.global_position - global_position
|
var distance_to_enemy: Vector2 = body.global_position - global_position
|
||||||
@@ -91,6 +94,8 @@ func _on_sword_area_2d_body_entered(body: Node2D) -> void:
|
|||||||
body.queue_free()
|
body.queue_free()
|
||||||
|
|
||||||
func attack():
|
func attack():
|
||||||
|
if not $Sword/SwordTimer.is_stopped():
|
||||||
|
return
|
||||||
var player_animation: String = $AnimatedSprite2D.animation
|
var player_animation: String = $AnimatedSprite2D.animation
|
||||||
if player_animation == "move_right":
|
if player_animation == "move_right":
|
||||||
$AnimatedSprite2D.play("attack_right")
|
$AnimatedSprite2D.play("attack_right")
|
||||||
@@ -125,3 +130,8 @@ func _on_sword_timer_timeout() -> void:
|
|||||||
$AnimatedSprite2D.play("move_up")
|
$AnimatedSprite2D.play("move_up")
|
||||||
if player_animation == "attack_down":
|
if player_animation == "attack_down":
|
||||||
$AnimatedSprite2D.play("move_down")
|
$AnimatedSprite2D.play("move_down")
|
||||||
|
|
||||||
|
|
||||||
|
func _on_death_timer_timeout() -> void:
|
||||||
|
get_tree().call_deferred("reload_current_scene")
|
||||||
|
SceneManager.player_hp = 3
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
[ext_resource type="Script" uid="uid://duilaa5lwqeup" path="res://Scenes/Player/player.gd" id="1_a3d8c"]
|
[ext_resource type="Script" uid="uid://duilaa5lwqeup" path="res://Scenes/Player/player.gd" id="1_a3d8c"]
|
||||||
[ext_resource type="Texture2D" uid="uid://cjbvc07lh4x1b" path="res://Ninja Adventure - Asset Pack/Actor/Characters/KnightGold/SeparateAnim/Walk.png" id="2_a3d8c"]
|
[ext_resource type="Texture2D" uid="uid://cjbvc07lh4x1b" path="res://Ninja Adventure - Asset Pack/Actor/Characters/KnightGold/SeparateAnim/Walk.png" id="2_a3d8c"]
|
||||||
[ext_resource type="Texture2D" uid="uid://cpuphg0fwkemr" path="res://Ninja Adventure - Asset Pack/Actor/Characters/KnightGold/SeparateAnim/Attack.png" id="2_dd0ac"]
|
[ext_resource type="Texture2D" uid="uid://cpuphg0fwkemr" path="res://Ninja Adventure - Asset Pack/Actor/Characters/KnightGold/SeparateAnim/Attack.png" id="2_dd0ac"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://cp2qfumar3lu" path="res://Ninja Adventure - Asset Pack/Actor/Characters/KnightGold/SeparateAnim/Dead.png" id="3_0u5uq"]
|
||||||
[ext_resource type="Texture2D" uid="uid://6dmy1j0t5mqy" path="res://Ninja Adventure - Asset Pack/Items/Scroll/ScrollEmpty.png" id="3_xpcdj"]
|
[ext_resource type="Texture2D" uid="uid://6dmy1j0t5mqy" path="res://Ninja Adventure - Asset Pack/Items/Scroll/ScrollEmpty.png" id="3_xpcdj"]
|
||||||
[ext_resource type="Texture2D" uid="uid://ff3wjwfsais6" path="res://Ninja Adventure - Asset Pack/Ui/LifeReceptacle/heart_2.png" id="4_mtuoh"]
|
[ext_resource type="Texture2D" uid="uid://ff3wjwfsais6" path="res://Ninja Adventure - Asset Pack/Ui/LifeReceptacle/heart_2.png" id="4_mtuoh"]
|
||||||
[ext_resource type="Texture2D" uid="uid://38ldil8moinv" path="res://Ninja Adventure - Asset Pack/Items/Weapons/Sword2/SpriteInHand.png" id="5_htcer"]
|
[ext_resource type="Texture2D" uid="uid://38ldil8moinv" path="res://Ninja Adventure - Asset Pack/Items/Weapons/Sword2/SpriteInHand.png" id="5_htcer"]
|
||||||
@@ -23,6 +24,10 @@ region = Rect2(48, 0, 16, 16)
|
|||||||
atlas = ExtResource("2_dd0ac")
|
atlas = ExtResource("2_dd0ac")
|
||||||
region = Rect2(16, 0, 16, 16)
|
region = Rect2(16, 0, 16, 16)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_ythyg"]
|
||||||
|
atlas = ExtResource("3_0u5uq")
|
||||||
|
region = Rect2(0, 0, 16, 16)
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_a3d8c"]
|
[sub_resource type="AtlasTexture" id="AtlasTexture_a3d8c"]
|
||||||
atlas = ExtResource("2_a3d8c")
|
atlas = ExtResource("2_a3d8c")
|
||||||
region = Rect2(0, 0, 16, 16)
|
region = Rect2(0, 0, 16, 16)
|
||||||
@@ -123,6 +128,14 @@ animations = [{
|
|||||||
}, {
|
}, {
|
||||||
"frames": [{
|
"frames": [{
|
||||||
"duration": 1.0,
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_ythyg")
|
||||||
|
}],
|
||||||
|
"loop": 1,
|
||||||
|
"name": &"death",
|
||||||
|
"speed": 5.0
|
||||||
|
}, {
|
||||||
|
"frames": [{
|
||||||
|
"duration": 1.0,
|
||||||
"texture": SubResource("AtlasTexture_a3d8c")
|
"texture": SubResource("AtlasTexture_a3d8c")
|
||||||
}, {
|
}, {
|
||||||
"duration": 1.0,
|
"duration": 1.0,
|
||||||
@@ -410,7 +423,7 @@ script = ExtResource("1_a3d8c")
|
|||||||
|
|
||||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="." unique_id=721334358]
|
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="." unique_id=721334358]
|
||||||
sprite_frames = SubResource("SpriteFrames_bqpwv")
|
sprite_frames = SubResource("SpriteFrames_bqpwv")
|
||||||
animation = &"attack_left"
|
animation = &"death"
|
||||||
autoplay = "move_down"
|
autoplay = "move_down"
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=129222135]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=129222135]
|
||||||
@@ -490,8 +503,13 @@ one_shot = true
|
|||||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="." unique_id=1687360666]
|
[node name="AnimationPlayer" type="AnimationPlayer" parent="." unique_id=1687360666]
|
||||||
libraries/ = SubResource("AnimationLibrary_jlvik")
|
libraries/ = SubResource("AnimationLibrary_jlvik")
|
||||||
|
|
||||||
|
[node name="DeathTimer" type="Timer" parent="." unique_id=1301433095]
|
||||||
|
wait_time = 1.5
|
||||||
|
one_shot = true
|
||||||
|
|
||||||
[connection signal="body_entered" from="HitBoxArea2D" to="." method="_on_hit_box_area_2d_body_entered"]
|
[connection signal="body_entered" from="HitBoxArea2D" to="." method="_on_hit_box_area_2d_body_entered"]
|
||||||
[connection signal="body_entered" from="InteractArea2D" to="." method="_on_area_2d_body_entered"]
|
[connection signal="body_entered" from="InteractArea2D" to="." method="_on_area_2d_body_entered"]
|
||||||
[connection signal="body_exited" from="InteractArea2D" to="." method="_on_area_2d_body_exited"]
|
[connection signal="body_exited" from="InteractArea2D" to="." method="_on_area_2d_body_exited"]
|
||||||
[connection signal="body_entered" from="Sword/SwordArea2D" to="." method="_on_sword_area_2d_body_entered"]
|
[connection signal="body_entered" from="Sword/SwordArea2D" to="." method="_on_sword_area_2d_body_entered"]
|
||||||
[connection signal="timeout" from="Sword/SwordTimer" to="." method="_on_sword_timer_timeout"]
|
[connection signal="timeout" from="Sword/SwordTimer" to="." method="_on_sword_timer_timeout"]
|
||||||
|
[connection signal="timeout" from="DeathTimer" to="." method="_on_death_timer_timeout"]
|
||||||
|
|||||||
Reference in New Issue
Block a user