initial commit
This commit is contained in:
39
Assets/Scripts/UI/crosshair.gd
Normal file
39
Assets/Scripts/UI/crosshair.gd
Normal file
@@ -0,0 +1,39 @@
|
||||
extends CenterContainer
|
||||
@export var dotRadius: float = 1
|
||||
@export var dotColor: Color = Color.WHITE
|
||||
|
||||
var current_radius: float
|
||||
var is_highlighted: bool = false
|
||||
var tween: Tween
|
||||
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
queue_redraw()
|
||||
pass # Replace with function body.
|
||||
|
||||
# This function is called by the Camera script
|
||||
func set_highlight(active: bool) -> void:
|
||||
is_highlighted = active
|
||||
_animate_radius()
|
||||
queue_redraw()
|
||||
|
||||
func _animate_radius():
|
||||
# Kill any existing tween so they don't fight each other
|
||||
if tween and tween.is_running():
|
||||
tween.kill()
|
||||
|
||||
tween = create_tween()
|
||||
|
||||
# Determine target based on state
|
||||
var target = dotRadius * 3 if is_highlighted else dotRadius
|
||||
|
||||
# Transition from current_radius to target over 0.3 seconds
|
||||
tween.tween_property(self, "current_radius", target, 0.1)\
|
||||
.set_trans(Tween.TRANS_SINE)\
|
||||
.set_ease(Tween.EASE_OUT)
|
||||
|
||||
|
||||
func _draw():
|
||||
draw_circle(Vector2(0,0),current_radius,dotColor)
|
||||
Reference in New Issue
Block a user