homework
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
extends Area2D
|
||||
@onready var animated = $AnimatedSprite2D
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
animated.play("IDLE")
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
|
||||
|
||||
func _on_body_entered(body: Node2D) -> void:
|
||||
if body.is_in_group("Player"):
|
||||
if animated.animation != "END":
|
||||
animated.play("END")
|
||||
await animated.animation_finished
|
||||
call_deferred("go_to_next_level")
|
||||
|
||||
func go_to_next_level():
|
||||
var player = get_tree().get_first_node_in_group("Player")
|
||||
if player:
|
||||
Global.player_HP = player.HP
|
||||
get_tree().change_scene_to_file("res://scene/entities/level_2.tscn")
|
||||
Reference in New Issue
Block a user