update player death and add global node enum
This commit is contained in:
@@ -15,6 +15,10 @@ run/main_scene="uid://cy3dg66pt8abt"
|
|||||||
config/features=PackedStringArray("4.5", "Forward Plus")
|
config/features=PackedStringArray("4.5", "Forward Plus")
|
||||||
config/icon="res://icon.svg"
|
config/icon="res://icon.svg"
|
||||||
|
|
||||||
|
[autoload]
|
||||||
|
|
||||||
|
NodeTypes="*res://scripts/NodeTypes.gd"
|
||||||
|
|
||||||
[rendering]
|
[rendering]
|
||||||
|
|
||||||
textures/canvas_textures/default_texture_filter=0
|
textures/canvas_textures/default_texture_filter=0
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
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
|
@onready var timer: Timer = $Timer
|
||||||
|
|
||||||
func _on_body_entered(_body: Node2D) -> void:
|
func _on_body_entered(player_body: Node2D) -> void:
|
||||||
print("You died.")
|
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()
|
timer.start()
|
||||||
|
|
||||||
|
|
||||||
func _on_timer_timeout() -> void:
|
func _on_timer_timeout() -> void:
|
||||||
|
Engine.time_scale = 1
|
||||||
get_tree().reload_current_scene()
|
get_tree().reload_current_scene()
|
||||||
|
|||||||
Reference in New Issue
Block a user