feat: add user's attack animation to the player's node;
This commit is contained in:
@@ -20,6 +20,8 @@ func _physics_process(delta: float) -> void:
|
||||
push_blocks()
|
||||
update_scrolls()
|
||||
move_and_slide()
|
||||
if Input.is_action_just_pressed("Interact"):
|
||||
attack()
|
||||
|
||||
func move_player():
|
||||
var move_vector: Vector2 = Input.get_vector("ui_left", "ui_right", "ui_up", "ui_down")
|
||||
@@ -71,3 +73,23 @@ func _on_hit_box_area_2d_body_entered(body: Node2D) -> void:
|
||||
func die():
|
||||
get_tree().call_deferred("reload_current_scene")
|
||||
SceneManager.player_hp = 3
|
||||
|
||||
func _on_sword_area_2d_body_entered(body: Node2D) -> void:
|
||||
body.queue_free()
|
||||
|
||||
func attack():
|
||||
if velocity.x > 0:
|
||||
$Sword.position = Vector2(0, 0.5)
|
||||
elif velocity.x < 0:
|
||||
$Sword.position = Vector2(-5, 2)
|
||||
elif velocity.y > 0:
|
||||
$Sword.position = Vector2(0, 8)
|
||||
elif velocity.y < 0:
|
||||
$Sword.position = Vector2(0, -4)
|
||||
$Sword.visible = true
|
||||
$Sword/SwordArea2D.monitoring = true
|
||||
$Sword/SwordTimer.start()
|
||||
|
||||
func _on_sword_timer_timeout() -> void:
|
||||
$Sword.visible = false
|
||||
$Sword/SwordArea2D.monitoring = false
|
||||
|
||||
Reference in New Issue
Block a user