update player death and add global node enum
This commit is contained in:
4
scripts/NodeTypes.gd
Normal file
4
scripts/NodeTypes.gd
Normal file
@@ -0,0 +1,4 @@
|
||||
extends Node2D
|
||||
|
||||
const COLLISION_SHAPE_2D = "CollisionShape2D"
|
||||
const CHARACTER_BODY_2D = "CharacterBody2D"
|
||||
1
scripts/NodeTypes.gd.uid
Normal file
1
scripts/NodeTypes.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dsc3ktvekmke7
|
||||
@@ -2,10 +2,15 @@ extends Area2D
|
||||
|
||||
@onready var timer: Timer = $Timer
|
||||
|
||||
func _on_body_entered(_body: Node2D) -> void:
|
||||
func _on_body_entered(player_body: Node2D) -> void:
|
||||
print("You died.")
|
||||
Engine.time_scale = 0.5
|
||||
player_body.get_node(NodeTypes.COLLISION_SHAPE_2D).queue_free()
|
||||
var player_character_body = player_body as CharacterBody2D
|
||||
player_character_body.velocity.y = -100
|
||||
timer.start()
|
||||
|
||||
|
||||
func _on_timer_timeout() -> void:
|
||||
Engine.time_scale = 1
|
||||
get_tree().reload_current_scene()
|
||||
|
||||
Reference in New Issue
Block a user