31 lines
931 B
GDScript
31 lines
931 B
GDScript
extends Node2D
|
|
|
|
onready var cull_edge = Vector2(5 * scale.x,0) #Edge to check culling, if this edge is offscreen, delete the arrow
|
|
onready var player = get_parent().get_node("Player")
|
|
onready var initial_sector = Game.get_sector(player.global_position)
|
|
|
|
func _ready():
|
|
#Flip depending on player facing
|
|
scale.x = player.sprite.scale.x
|
|
|
|
func _physics_process(delta):
|
|
#Move in flip direction
|
|
position.x += 4 * scale.x
|
|
#Delete when offscreen
|
|
if Game.get_sector(global_position + cull_edge) != initial_sector:
|
|
queue_free()
|
|
|
|
func _exit_tree():
|
|
# make sure particles node sticks around until particles decay
|
|
var particles = $DustParticles
|
|
remove_child(particles)
|
|
particles.global_position = global_position
|
|
particles.emitting = false
|
|
get_parent().add_child(particles)
|
|
particles.get_node("DeathTimer").start()
|
|
|
|
#Wall Collision
|
|
func _on_Area2D_body_entered(body):
|
|
if body is TileMap or body is StaticBody2D:
|
|
queue_free()
|
|
|