feat: 添加敌人并且追踪player,同时避免敌人重叠

This commit is contained in:
luke358
2026-05-17 21:02:46 +08:00
parent b678b90883
commit 67ea3f2d42
37 changed files with 543 additions and 4 deletions
+40
View File
@@ -0,0 +1,40 @@
extends Line2D
class_name Trail
@export var player: Player
@export var trail_length := 25
@export var trail_duration := 1.0
@onready var trail_timer: Timer = %TrailTimer
var pointers_array: Array[Vector2] = []
var is_active := false
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
if not is_active:
return
pointers_array.append(player.global_position)
if pointers_array.size() > trail_length:
pointers_array.pop_front()
points = pointers_array
func start_trail() -> void:
is_active = true
clear_points()
pointers_array.clear()
trail_timer.start(trail_duration)
func _on_trail_timer_timeout() -> void:
is_active = false
clear_points()
pointers_array.clear()